2022-12-27 19:46:17 +02:00
|
|
|
from app import app
|
2023-01-05 14:08:08 +02:00
|
|
|
from os import getpid, makedirs, path
|
2022-12-11 20:52:02 +02:00
|
|
|
from sys import exit
|
2023-01-05 14:08:08 +02:00
|
|
|
from time import time
|
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
|
2023-01-05 14:08:08 +02:00
|
|
|
from modules.utils import configGet, jsonSave, 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()
|
|
|
|
|
2023-01-05 14:08:08 +02:00
|
|
|
# Reboot command ===============================================================================================================
|
2023-01-03 22:46:16 +02:00
|
|
|
@app.on_message(custom_filters.enabled_general & ~filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]) & custom_filters.admin)
|
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()
|
2023-01-05 14:08:08 +02:00
|
|
|
makedirs(configGet("cache", "locations"), exist_ok=True)
|
|
|
|
jsonSave({"timestamp": time()}, path.join(configGet("cache", "locations"), "shutdown_time"))
|
2022-12-27 19:46:17 +02:00
|
|
|
exit()
|
2022-12-05 19:49:51 +02:00
|
|
|
# ==============================================================================================================================
|