If my .py code for the Telegram bot hasn't been

running for 6 hours and during that time, 5000 messages have been sent to the bot, will my bot respond to all 5000 messages or just 100? 🤖🕒📊👀

21 ответов

17 просмотров

If your code is not a total shit than to 5000, it will just take 50 requests to get all of them

s0m31 🇷🇺
If your code is not a total shit than to 5000, it ...

How will it read 5000 entries if the limit of getUpdates is 100?

s0m31 🇷🇺
by passing different offsets?

How do you know how many messages came in if the bot was offline?

Егор
How do you know how many messages came in if the b...

just count each one that you receive when you go online?

s0m31 🇷🇺
just count each one that you receive when you go o...

You just said that the limit is 100, how do you count all of them then (presumably, the actual message count of the messages outside the limit can be anything from 100 to e.g. 10000)? To my understanding you can’t get the exact count of messages straight away and if we would go the date route, then we would have to continue fetching getUpdates until we get to that exact “shut off” date, requiring us to loop through all of the messages, which doesn’t sound optimal

Егор
You just said that the limit is 100, how do you co...

Straight away - yes. You are looping through updates all the time when bot is running using polling, why not do it again? You don't even need an extra loop for that

s0m31 🇷🇺
Straight away - yes. You are looping through updat...

The bot was off, after it comes back from the hiatus it gets to read the last 100. So the queue would be backwards, as in the freshest messages get processed first and then the older ones?

Егор
The bot was off, after it comes back from the hiat...

Did you ever code your bot where you did not just let library do all the updates parsing part for you?

s0m31 🇷🇺
Did you ever code your bot where you did not just ...

I coded the polling mechanism I had by myself to your surprise, there’s no need to get passive aggressive. I was just trying to understand your standpoint since the Telegram API is still new for me

KK-Sumit Автор вопроса
s0m31 🇷🇺
Did you ever code your bot where you did not just ...

so you say, in website of getupdate there will show 100 message, but when i use library like ptyhon-tleegram-bot, and run my code bot will response other message which is not in getupdat???

Егор
I coded the polling mechanism I had by myself to y...

My messages looking aggressive is a problem for me that I can't really solve: I am not putting any hate in them, that's just the style I am writing. Sorry if that somehow... Touched you? Anyway, back to the point. I find it really weird that you don't understand how polling works. There's a limit you can get in a single request. And each update has an ID (not different for vk com/any polling Ive made by myself). If a program does not know the latest id, it will receive all the old updates before their amount hits the limit. Then it stores latest id and uses it in a new polling request. And the server is removing old updates from pending list (aka it is impossible to get same update twice if you already willed to get a newer one) and sending only newer ones

s0m31 🇷🇺
My messages looking aggressive is a problem for me...

When I was developing my bot, I always had the messages stack up in the getUpdates request, the ones shown to me before I call the endpoint again didn’t ever go away

Егор
When I was developing my bot, I always had the mes...

For instance you have update with id 1. Once you make new request with offset_id=2, telegram will not ever return update 1 again. Even if you set offset back to 0/1

s0m31 🇷🇺
For instance you have update with id 1. Once you m...

So we can get the latest message ID and the offset ID saved in the DB, that way we can offset till that value, and if we would have message 5000 as the last one, when our bot came back to life getUpdates would show us the latest ID, let’s say 15000, so we can subtract and calculate the offset IDs as 1 per 100 messages?

Егор
So we can get the latest message ID and the offset...

I don't quite understand your plan. When your bot comes back to life, just set offset to an zero. As I said before, confirmed updates would not get listed anymore. That's how I always do it. Then you will receive 100 updates in a FIFO order. Remember the latest update id there and use (it+1) in next getupdates. Once you finish getting old ones and finally got into waiting, subtract latest known update id from one you have stored in db

s0m31 🇷🇺
I don't quite understand your plan. When your bot ...

Alright, thanks for bearing with me, I guess I have to experiment more :D (and get through the docs more carefully)

Did you read all messages I've sent to egor?

KK-Sumit Автор вопроса
s0m31 🇷🇺
Did you read all messages I've sent to egor?

there was a lot of technical words very hard to understand the meaning

KK Sumit
there was a lot of technical words very hard to un...

That way or another I have answered your question already: https://t.me/BotTalk/814369

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

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

Эх кто-то пришел и весь праздник испортил :( You need complex FBX scene importing setup to change things on import? good luck with that. You need navigation and pathfinding? g...
Serg Gini
5
Кстати @darkhole1 для rich telegram app с поддержкой транзакций p2p через ton - какой язык считается с самой хорошей поддержкой?
Serg Gini
3
есть спецы по гитлабу? нужно решить проблему того, что гитлаб не показывает файлы с расширением txt в артефактах и предлагает их скачать и смотреть локально. а это неудобно. в...
Aleksandr Druzhinin
1
Здравствуйте. Есть спецы на языке D ? Есть проект (торговый бот) нужна долгосрочная поддержка на материальной основе) (достойная оплата) Подробности в лс.
6h123 6h123
1
как работают все эти прокси онлайн, где ты можешь ввести сайт и он зайдет на сайт от своего имени?
Aleksandr Druzhinin
1
День добрый. Стандартная библиотека phobos (std.array) ссылается на внешнюю фунцию _d_newarrayUTrace и при сборке с ключом profile-gc эта ссылка остаётся неопределённой. Никак...
slacker linuxoid
5
на D можно построить абсолютно разный архитект, как объектный, так и нет, оч широкий простор для принятия решений. Однако проблема в том, что большинство книг об айтишной архи...
Constantin_FV
1
Доброго времени суток. Сейчас я работаю над своей архитектурой Component / Systems. Если просто, это то что использовали до дробления на ECS. Потому что ECS это все таки нишев...
Vi
26
Для меня наследование это просто удобство ради удобства. Без множественного наследования, это бесполезная вещь, но удобная. С множественным наследованием, это опасная, но мощн...
Vi
1
string xczhojoxueaflfhhygcc ="xczhojoxueaflfhhygcc"; long xczhojoxueaflfhhygcc_2 =1368962155; import std.conv: text; writeln(text(xczhojoxueaflfhhygcc, " ", xczhojoxueaflfhhyg...
Constantin_FV
6
Карта сайта