[check] add the updater function

This commit is contained in:
levina 2022-03-01 21:16:39 +07:00 committed by GitHub
parent 6386e0a8ae
commit 307aa2bb11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,20 @@ from driver.decorators import bot_creator
from driver.database.dbqueue import get_active_chats, remove_active_chat 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) @Client.on_message(command(["update", f"update@{BOT_USERNAME}"]) & ~filters.edited)
@bot_creator @bot_creator
async def update_bot(_, message: Message): async def update_bot(_, message: Message):