Telethon: Unable to join private channel using telegram's new invite hash format.
It is no longer possible to join a private channel via their invite links/hashes. I will provide a proof of concept of the failure and the corresponding error log below.
import asyncio
from telethon.sync import TelegramClient
from telethon.tl.functions.messages import ImportChatInviteRequest
async def main():
tg_hash = '<enter_invite_hash_here>'
async with TelegramClient('anon', <enter_API_id_here>, '<enter_API_hash_here>') as client:
chat_invite = await client(ImportChatInviteRequest(tg_hash))
asyncio.run(main())
File "test.py", line 27, in main
chat_invite = await client(ImportChatInviteRequest(tg_hash))
File "/home/test/.local/lib/python3.7/site-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "/home/test/.local/lib/python3.7/site-packages/telethon/client/users.py", line 79, in _call
result = await future
telethon.errors.rpcerrorlist.InviteHashExpiredError: The chat the user tried to join has expired and is not valid anymore (caused by ImportChatInviteRequest)
Raises InviteHashExpiredError even when:
- After stripping/remove ‘+’ character from the telegram invite hash string (example: hlQ3QhNi6q05ZDIx).
- Providing full telegram invite hash string (example: +hlQ3QhNi6q05ZDIx
- Providing full telegram invite hash string with link/t.me domain (example: https://t.me/+hlQ3QhNi6q05ZDIx)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 20 (3 by maintainers)
I think the main reason caused links which are required admin approval to join.
I have tested regular links - it is working Admin approval links are not working
Closing since v1.25 available in PyPi should accept the new invite link hash.
API ID and hash to not affect how the API behaves (to my knowledge). The layer used (which is the latest in the development version) does though.