Closed Roma-Kyrnis closed 7 months ago
Last crash with more logs:
I understand maybe it's a problem with TDL, but why grammy stops to respond?
Do you use several instances of TDLib?
Yes, There are many users that connects to this bot (connect to TDLib through this bot)
That does not mean that you need several instances of TDLib. A bot isn't allowed to connect to different instances. You first need to explicitly log out of one and then start contacting another instance. Otherwise, updates may get lost.
TDLib can easily handle 500,000,000 messages per day with a single instance. If you don't have substantially more traffic than that, then your setup is overkill (=harmful). Most likely, you should only be using a single instance..
If I'll use one TDLib instance I need to login different users.
Maybe you can recommend a topic what to read?
If I need to send message, receive chats for specific user than I need to use telegram ID on this instance, as I understand it.
I found this PR, it recommends to create a lot of instances.
I understand you try to help. Can you point me where to look?
It has nothing to do with bots.
What are you even trying to do?
I make an application to send regular messages from different accounts to the chats, like ads or notifications.
I've tested that TDLib is still receiving updates when bot stops to work. But not is not responding on other calls, bot is not calling getUpdates function to pull messages from Telegram. That's why I'm here
I want to test why it happens and solve the issue
Could you help?
So your bot doesn't actually use the TDLib instances? In other words, your bot still connects to api.telegram.org
?
Usually, if the bot stops, that's because a handler never completes. Do you have any handlers that could take a very long time, potentially forever?
Yes, I send a request to get users chats.
I'm using "tdl" npm lib. User enter app_ia and app_hash etc. And then I can send messages from a users account to chats
Thank you! I think that the issue. But I don't get the logic here: bot waits until long request to get Chats from TDLib for example, but never receive. Does not telegram bot should work asynchronous and handle other requests while this one is processing?
Oh, maybe it's because you run a loop and wait for getUpdate function to resolve. And while you waiting you cannot send a new getUpdate?
I've seen this behaviour on the tdl lib: Here https://github.com/Bannerets/tdl In packages/tdl/index There is a loop for processing long pull requests to Telegram
I didn't quite catch you when you said: 'connect to telegram.com'. Does TDLib and Telegram bot both connecting to telegram servers?
By default, grammY handles all updates in sequence. This is enough for 90 % of bots, and it leads to very simple and predictable behaviour. For example, in your case, you were able to find out that a handler takes way too much time. In a concurrent setup, this would have been much harder to detect, and your bot would probably just randomly OOM after a few weeks. Now you know, so you can fix it.
If you want to run your bot concurrently at a later point, you can use grammY runner.
TDLib is used internally by the Bot API server. You can read more in the docs. https://grammy.dev/guide/api
Thank you! I've got the point what I need to change ;)
I'll read the docs.
Have you thought about implementing the user's TDLib methods in Grammy?
That is not possible. grammY is not an MTProto client. It's a completely different API and you'll need to use a completely different library for that, such as https://github.com/MTKruto/MTKruto
Okay, thank you for the quick response and for the library creation)
May I join in implementing new features in the future, maybe in 1-2 months? I'm not sure if I will have time... Just interesting in this topic: https://github.com/grammyjs/grammY/issues/110
Absolutely! Feel free to drop a message to https://t.me/grammyjs if you have questions or need advice. Looking forward to your contributions!
Have you thought about implementing the user's TDLib methods in Grammy?
its possible via https://github.com/tdlight-team/tdlight-telegram-bot-api , they offer user MTProto methods over bot api - means you can use grammy to interact w/ user account. However you need to change api endpoints from /bot[token] to /user[token]
Read their docs for more information. I've been using it for few months and as long as its updated its all good.
Hi, I'm using TDLib with Grammy bot. Flow:
As I understand my function has stopped and bot is waiting for this function. How to solve this?
I've used: export DEBUG = "grammy*".
Can you help to find a reason of the bot stop?