This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/commands/reboot.py

19 lines
880 B
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from app import app, isAnAdmin
from os import getpid
2022-12-11 20:52:02 +02:00
from sys import exit
2022-12-05 19:49:51 +02:00
from pyrogram import filters
2022-12-11 20:52:02 +02:00
from modules.utils import configGet, logWrite, should_quote
from modules.scheduled import scheduler
2022-12-05 19:49:51 +02:00
pid = getpid()
# Shutdown command =============================================================================================================
@app.on_message(~ filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]))
async def cmd_kill(app, msg):
2022-12-15 15:31:42 +02:00
if await isAnAdmin(msg.from_user.id) is True:
2022-12-05 19:49:51 +02:00
logWrite(f"Shutting down bot with pid {pid}")
await msg.reply_text(f"Вимкнення бота з підом `{pid}`", quote=should_quote(msg))
2022-12-11 20:52:02 +02:00
scheduler.shutdown()
exit()
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================