35 lines
1016 B
Python
35 lines
1016 B
Python
from app import app
|
|
from os import getpid, makedirs, path
|
|
from sys import exit
|
|
from time import time
|
|
from pyrogram import filters
|
|
from pyrogram.types import Message
|
|
from pyrogram.client import Client
|
|
from modules.utils import configGet, jsonSave, locale, logWrite, should_quote
|
|
from modules.scheduled import scheduler
|
|
from modules import custom_filters
|
|
|
|
pid = getpid()
|
|
|
|
|
|
@app.on_message(
|
|
custom_filters.enabled_general
|
|
& ~filters.scheduled
|
|
& filters.private
|
|
& filters.command(["kill", "die", "reboot"], prefixes=["/"])
|
|
& custom_filters.admin
|
|
)
|
|
async def cmd_kill(app: Client, msg: Message):
|
|
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()
|
|
makedirs(configGet("cache", "locations"), exist_ok=True)
|
|
jsonSave(
|
|
{"timestamp": time()},
|
|
path.join(configGet("cache", "locations"), "shutdown_time"),
|
|
)
|
|
exit()
|