From 2ed5069985f2055b93f02c6049cc2b172ea9dd4a Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 16 Nov 2021 05:22:53 +0700 Subject: [PATCH] add restart --- program/updater.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/program/updater.py b/program/updater.py index c4d85d0..9dd57c9 100644 --- a/program/updater.py +++ b/program/updater.py @@ -50,6 +50,7 @@ def updater(): @Client.on_message(command(["update", f"update@{BOT_USERNAME}"]) & ~filters.edited) +@sudo_users_only async def update_repo(_, message: Message): chat_id = message.chat.id msg = await message.reply("šŸ”„ `processing update...`") @@ -60,3 +61,13 @@ async def update_repo(_, message: Message): execle(sys.executable, sys.executable, "main.py", environ) return await msg.edit("bot is **up-to-date** with [main](https://github.com/levina-lab/video-stream/tree/main)", disable_web_page_preview=True) + + +@Client.on_message(command(["restart", f"restart@{BOT_USERNAME}"]) & ~filters.edited) +@sudo_users_only +async def restart_bot(_, message: Message): + msg = await message.reply("`restarting bot...`") + args = [sys.executable, "main.py"] + await msg.edit("āœ… bot restarted\n\nā€¢ now you can use this bot again.") + execle(sys.executable, *args, environ) + return