Похожие чаты

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 ответов

16 просмотров

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

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

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

30500 за редактор? )
Владимир
47
any reference of this implementation?
BitBuddha
29
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
9
Anyone else having this error when trying to make transactions?
Datzel
11
Question: How viable is it to use Anvil as the backend infrastructure for managing a TradFi portfolio, while integrating Flexa for instant liquidity and payment solutions? Cou...
Kevin
2
вы делали что-то подобное и как? может есть либы готовые? увидел картинку нокода, где всё линиями соединено и стало интересно попробовать то же в ddl на lua сделать. решил с ч...
Victor
8
Карта сайта