LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.77k stars 1.39k forks source link

CheckChatInviteRequest not working properly #3945

Closed thomassjastad closed 1 year ago

thomassjastad commented 1 year ago

Checklist

I try to get the name or information of a Group or Channel by CheckChatInviteRequest, and has worked flawlessly untill just now today. code and error message below.

Code that causes the issue


from telethon.sync import TelegramClient
from telethon import TelegramClient, events
from telethon import TelegramClient, events, sync, functions

api_id = id
api_hash = hash

with TelegramClient('session', api_id, api_hash) as client:
    result = client(functions.messages.CheckChatInviteRequest(
                                                hash='AnyNameOrHash'
                                                ))
    print(result.stringify())

**Traceback**

Traceback (most recent call last): Traceback (most recent call last): File "C;\ . . . \tg_test.py", line 14, in result = client(functions.messages.CheckChatInviteRequest( File "C:. . .\Python\Python39-32\lib\site-packages\telethon\sync.py", line 39, in syncified return loop.run_until_complete(coro) File "C:. . .\Python\Python39-32\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "C:. . ..\Python\Python39-32\lib\site-packages\telethon\client\users.py", line 30, in call return await self._call(self._sender, request, ordered=ordered) File "C:. . .\Python\Python39-32\lib\site-packages\telethon\client\users.py", line 84, 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 CheckChatInviteRequest)

thomassjastad commented 1 year ago

This is still giving error at random times.

Lonami commented 1 year ago

You are using raw API, which means the results you are getting come directly from Telegram, and Telethon is not changing them in any way (other than adapting some input parameters where needed, all while respecting the intended values). Unfortunately this means it's something Telethon cannot "fix" and it's just the way Telegram's API works.