From 307aa2bb118af695b8c646ed0392917dc838a636 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 1 Mar 2022 21:16:39 +0700 Subject: [PATCH] [check] add the updater function --- program/updater.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/program/updater.py b/program/updater.py index 6e1067c..afd5610 100644 --- a/program/updater.py +++ b/program/updater.py @@ -33,6 +33,20 @@ from driver.decorators import bot_creator from driver.database.dbqueue import get_active_chats, remove_active_chat +async def install_requirements(cmd: str) -> Tuple[str, str, int, int]: + args = shlex.split(cmd) + process = await asyncio.create_subprocess_exec( + *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE + ) + stdout, stderr = await process.communicate() + return ( + stdout.decode("utf-8", "replace").strip(), + stderr.decode("utf-8", "replace").strip(), + process.returncode, + process.pid, + ) + + @Client.on_message(command(["update", f"update@{BOT_USERNAME}"]) & ~filters.edited) @bot_creator async def update_bot(_, message: Message):