Похожие чаты

Hello guys, I need a very low-level advice if someone

has that knowledge, I'm trying to interact with a third-party bot, and when I'm clicking the bot MessageButtons using the usual mobile phone client i can observe the results very quickly, but when I'm using telethon to click them, there is a massive delay in the program. Most probably it is caused by the fact that the bot doesn't have answer_callback_query implemented in its code (yeah, lame, but unfortunately it's third party), and the telethon client is waiting for some ~20 seconds for a response, not getting any, and only then proceeding with the next one.
So the questions are:
1) is it possible to somehow override the telethon behaviour for request to make it more like telegram's official client that allows to click a lot of buttons without waiting for each request to resolve
or
2) is it somehow possible to modify the request to not receive bot answer at all, just to send the "clicking" part to telegram servers? I don't really need the answer and if I could just fire and forget only "the clicking" part it would be alright
or
3) is it at least possible to reduce somewhere the time gap for which the telethon is trying to get an answer? so say instead of 20 seconds it becomes like 2, click and forget

Unfortunately my knowledge of this lower-level implementations is poor, I've dug down to the click() implementation and i think this is the faulty place:
try:
return await self._client(req)
except BotResponseTimeoutError:
return None

unfortunately I then dug down to client._call and there I can't see where and how the BotResponseTimeoutError is raised or any parameters to influence it, I only see retry attempts number but not sure if it would change anything as it might be really 1 attempt but a long one

Thanks a lot for any input

5 ответов

18 просмотров

Every call of client(req) has to return a result or raise rpc error to the context before the code proceeds in same context if you don't care about the return, you can fire and forget it as a task or cancel if it takes too long but you need the result, read about asyncio.wait_for() and set a timeout, average bot should take less than 2 seconds to deliver a response, you can also then expand on this and create a task for each button to click. abort the remaining when one returns or whatever you intend with asyncio.wait

Alex- Автор вопроса
⎞ .·. ⎝ ⎝
Every call of client(req) has to return a result o...

> average bot should take less than 2 seconds to deliver a response that's exactly the problem, the bot that I have to use is third party, lame designed and don't have answer_callback_query implemented in the call handler, as such, telethon's waiting for like 20 seconds to throw a bot response error. I will try wait_for, I never heard about it. it can cancel the request resolving, right? that's what you mean?

Alex
> average bot should take less than 2 seconds to d...

Telethon is doing what it should. it's telegram kinda at fault for not timing out earlier, that's just intended. try: callback = await asyncio.wait_for(message.click(...), timeout=2) except asyncio.TimeoutError: callback = None you can abort the awaiting if your code must proceed like that

Alex- Автор вопроса
⎞ .·. ⎝ ⎝
Telethon is doing what it should. it's telegram ki...

yeah, I'm not blaming telethon or anything, I'm just curious if anything can be modified a bit. after all, in the official telegram client i can click those buttons rapidly and it will work fine, so was just thinking if something is possible to do here. thanks a lot again, i will try as soon as I can , looks promising ;)

yes it is one attempt but a long one. telegram waits for the bot's answer before returning the result. if you want to fire-and-forget, use asyncio.create_task

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта