Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event.answer(url) not working when handled with bot.add_event_handler #4002

Closed
pdisk opened this issue Dec 17, 2022 · 3 comments
Closed

event.answer(url) not working when handled with bot.add_event_handler #4002

pdisk opened this issue Dec 17, 2022 · 3 comments

Comments

@pdisk
Copy link

pdisk commented Dec 17, 2022

event.answer(url="t.me/botname/start?=hi") not working when handled with client.add_event_handler() to assign event handlers
its working fine when I use @client.on(event) (decorator method) instead of add_event_handler()

Traceback

File "C:\Users\..\Python310\lib\site-packages\telethon\client\updates.py", line 467, in _dispatch_update
    await callback(event)
  File "C:\Users\..\event_handlers.py", line 213, in upl
    await e.answer(url=f"https://t.me/{await bot_username(client)}?start=hi")
  File "C:\Users\...\telethon\events\callbackquery.py", line 244, in answer
    return await self._client(
  File "C:\Users\...\Python310\lib\site-packages\telethon\client\users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "C:\Users\...\Python310\lib\site-packages\telethon\client\users.py", line 84, in _call
    result = await future
telethon.errors.rpcerrorlist.QueryIdInvalidError: The query ID is invalid (caused by SetBotCallbackAnswerRequest)

@Lonami
Copy link
Member

Lonami commented Dec 17, 2022

@client.on(...) simply calls client.add_event_handler():

def on(self: 'TelegramClient', event: EventBuilder):
"""
Decorator used to `add_event_handler` more conveniently.
Arguments
event (`_EventBuilder` | `type`):
The event builder class or instance to be used,
for instance ``events.NewMessage``.
Example
.. code-block:: python
from telethon import TelegramClient, events
client = TelegramClient(...)
# Here we use client.on
@client.on(events.NewMessage)
async def handler(event):
...
"""
def decorator(f):
self.add_event_handler(f, event)
return f
return decorator

Could you post a small code sample needed to reproduce the issue? What steps should I take while running the code to see the behavior you describe?

@pdisk pdisk closed this as completed Jan 12, 2023
@pdisk pdisk reopened this Jan 12, 2023
@pdisk
Copy link
Author

pdisk commented Jan 12, 2023

It's Working when i made a test code but its not working in production with as many as 5bots with 800k users all running on same code

Maybe its cuz the event is taking too much time to get processed idk

@Lonami
Copy link
Member

Lonami commented Jan 14, 2023

I am unable to reproduce this issue (I tried with your URL, and also t.me/botname?start=hi, as well as with https:// before both, but it kept failing with URL_INVALID).

I am going to close this under the assumption that the problem was in fact a timeout as you point out (I do get the error you describe if I put a normal answer('text'), with a long asyncio.sleep just before).

If you manage to reproduce this issue again, have a way for me to reliably trigger the error, and are certain it's not timing out (by noticing that the time between click and response is fast enough), let me know, and we can reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants