Answer the question
In order to leave comments, you need to log in
Telegram bot. Sending to multiple users. How to implement?
There was such a task. There is a Telegram bot. In it I want to do something like registration. The user sends a certain set of numbers (id). If this id is contained in the database, then write the user's chat_id to a file. Otherwise, do not record.
There is another script that performs some operations and returns information that needs to be sent to telegrams. Now the question is: do I have the chat_id of the users in a file. How to transfer them all to the bot? Or to implement everything differently, and if so, how?
To work with Telegram I use this library
Answer the question
In order to leave comments, you need to log in
I may not have understood the question very well ...
There is an example directly from your link, take it and call it in a loop
>>> bot.sendMessage(chat_id=chat_id, text="I'm sorry Dave I'm afraid I can't do that.")
Judging by this answer, you should already store all the chat_id where you want to send on your side.
The simplest thing is to make a channel in a telegram and make the bot an administrator. So you can send messages to everyone who is subscribed to the channel.
If you send it to everyone in a loop, sorting through the ID, then there are limitations. Recommend no more than one message per second.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question