R
R
RA4INA2021-07-06 12:37:20
Python
RA4INA, 2021-07-06 12:37:20

How to send a message from a bot to multiple users?

I know that you can send messages from the bot using the API:
https://api.telegram.org/bot <YOUR_TOKEN>/sendMessage?chat_id=&text=<TEXT>

But how can I send a message to several people at once in this way? Is it really possible to make such a link for each id

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MarkSmersh, 2021-07-08
@RA4INA

First we need to collect the chat_id of the users. For example, when the user writes the '/start' command, the function would be:
chat_id = update.message.chat.id
Write this value to the list, or to the database (at least to a text file)
After that, we do the sending itself. I would do it like this:

bot = Bot(токен_бота)
for user_number in range(len(список_с_пользователями)):
    chat_id = список_с_пользователями[user_number]
    bot.send_message (
        text = 'То, что ты хочешь написать',
        chat_id = chat_id)

The bot will send messages to users until the list ends
(taken from the comments so that the question does not stagnate)

S
soremix, 2021-07-06
@SoreMix

Is it really possible to make such a link for each id

Yes

A
Andrey, 2021-07-06
@anerev

No, well, but in the sense, you wanted to send messages without id, how is that in general?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question