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

21 lines
956 B
Python
Raw Normal View History

2022-12-27 19:46:17 +02:00
from app import app
2022-12-05 19:49:51 +02:00
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-27 14:36:54 +02:00
from pyrogram.types import Message
from pyrogram.client import Client
2022-12-17 01:58:33 +02:00
from modules.utils import locale, logWrite, should_quote
2022-12-11 20:52:02 +02:00
from modules.scheduled import scheduler
2022-12-27 19:46:17 +02:00
from modules import custom_filters
2022-12-05 19:49:51 +02:00
pid = getpid()
# Shutdown command =============================================================================================================
2022-12-27 19:46:17 +02:00
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]))
2022-12-27 14:36:54 +02:00
async def cmd_kill(app: Client, msg: Message):
2022-12-05 19:49:51 +02:00
2022-12-27 19:46:17 +02:00
logWrite(f"Shutting down bot with pid {pid}")
await msg.reply_text(locale("shutdown", "message", locale=msg.from_user).format(pid), quote=should_quote(msg))
scheduler.shutdown()
exit()
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================