E
E
Egor Stavitsky2019-06-05 22:39:15
Python
Egor Stavitsky, 2019-06-05 22:39:15

How to send a message from a bot to multiple users at the same time?

Hi, I'm making a mailing bot, and I can't figure out how to send a message to several users at the same time! I have id of all users! I send via
bot.send_message

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2019-06-05
@kshnkvn

ids = open('ids.txt', 'r')
for id in ids:
    bot.send_message(chat_id=id, text="Test text")

Enter the ID in the text file ids.txt, each on a new line.
You can run it in several threads, only then you need to add a condition so that each of the threads processes a certain number of IDs in order to avoid duplication of sent messages.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question