Answer the question
In order to leave comments, you need to log in
How to restart the bot?
I added .py files to the directory through the bot
. Now I want to completely restart the bot, by entering the command in the bot itself, i.e. fully load all files with command handlers on a new one.
Does anyone have any ideas how this can be done?
Answer the question
In order to leave comments, you need to log in
My bot is launched by the supervisored service, it can restart the script when it completely crashes, but it didn’t work for me to end the bot from the function, the process does not end.
For now I use for telegram (python-telegram-bot)*:
def cmd_restart_service(update, context):
if update.message.from_user.id == 777777777: # id пользователя
import subprocess
update.message.reply_text("будет исполнено...")
subprocess.run("sudo supervisorctl restart mybotname".split())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question