L
L
leviathan2020-05-16 18:18:50
Python
leviathan, 2020-05-16 18:18:50

Running bots from the database?

Task: launch a lot of bots, with the possibility of adding new ones.
Launch example

for item in bot_list:
                updater = Updater(
                    token=item.token,
                    use_context=True
                )

This option works well, however, if you add a new token to the database, or change an existing one, the bot will continue to work with the old data, you have to restart the bot.
Tell me, how can this be implemented in the context of the python-telegram-bot module?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-05-16
@The_Lars

Correctly.
How should the bot know that the token has changed in some database?
How to change the token on the fly in a running bot?
You probably need a service (a separate program) that will check the database and kick bots if something has changed.

N
Nikolay, 2020-05-16
@SODINNER

Well, what's the problem then? You found a "bug", now think about what needs to be done to fix it.
You need to either update bot_list once in a while with new data from the database, or most likely repeat the cycle, because it goes through once and that's it, with a check already, whether such a bot is already working - if so, then we skip it.
Learn to think on your own, to understand what happens in general, for this you don’t even need to be able to program, you need to be able to think logically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question