H
H
http20002022-02-03 00:18:59
Python
http2000, 2022-02-03 00:18:59

How to make a mailing to users of a telegram bot in python?

I'm trying to make the first bots in Telegram in Python. I use the telebot library (pyTelegramBotAPI).
I need to send a message to all users who have started the bot.
I understand, we save their id somewhere. Then, for example, we loop through them and send a message to each like this:

for user_id in users:
        bot.send_message(user_id, 'message')

But I can't understand - if we have launched a telegram server poll using bot.polling - the script doesn't go any further, does it? How can I run a loop to send messages to users at the same time as bot.polling(none_stop=True) is enabled?
I need to launch a mailing list NOT in response to a specific message, but at a specific time. It turns out that you will not call it through the handler of incoming messages. I need to simultaneously process incoming messages and send out mailings at a certain hour. How to implement it?
Thanks in advance for your replies!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2022-02-03
@http2000

You can simply run another script that will create a telebot object with the same token, but will not use polling, but will immediately call send_message as many times as necessary. But we must not forget about the rate limit.
PS: Why do they ask here every week about mailing list bots? Are there really no more interesting learning tasks?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question