Telethon
Telethon copied to clipboard
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)
Have you installed the development version to test this? Please use the issue templates. They exist for a reason.
I've tested it with my own API hash and API ID.
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.
I have same problem , did you solved it ?
I've tested it with my own API hash and API ID.
Same issue
Hi. I have faced the same issue. Here is a solution:
- Use hash without "+" character, like in your first example.
- Call the API like above:
await client(ImportChatInviteRequest(hash=tg_hash))
Hi. I have faced the same issue. Here is a solution:
- Use hash without "+" character, like in your first example.
- Call the API like above:
await client(ImportChatInviteRequest(hash=tg_hash))
Thanks , and how can we get entity of the group?
assign the result to this await
channel = await client(ImportChatInviteRequest(hash=tg_hash))
I use await client(ImportChatInviteRequest(hash='hlQ3QhNi6q05ZDIx'))
but it can't work
Any ideias how to make this work? Not able to join a private channel with the invite links that have a + sign, strip it or not
i got the same Problem. Any Ideas to fix it?
I also am getting this problem
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
Same problem. Does anybody solved it?
yes, i solved it. i changed https://t.me/+ab12xxxxxxx to https://t.me/joinchat/ab12xxxxxx
yes, i solved it. i changed https://t.me/+ab12xxxxxxx to https://t.me/joinchat/ab12xxxxxx
But problem in hash ab12xxxxxx, without +, /joinchat/ or anything else in url. ImportChatInviteRequest(hash='hlQ3QhNi6q05ZDIx')) doesn't accept hash, it return an error.
Anyway, somebody says, that I can use newthon. It solve the problem.
i use client.get_entity(chan_url) did you use excatly the same format? https://t.me? if /joinchat/ isn present, add it... i try it in browser first. build the correct url.
Closing since v1.25 available in PyPi should accept the new invite link hash.
I have same problem. Did somebody solve it?
Same problem, telebot 1.3x