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.

24 lines
1.2 KiB
Python
Raw Normal View History

2022-12-27 18:46:17 +01:00
from app import app
2023-01-05 13:08:08 +01:00
from os import getpid, makedirs, path
2022-12-11 19:52:02 +01:00
from sys import exit
2023-01-05 13:08:08 +01:00
from time import time
2022-12-05 18:49:51 +01:00
from pyrogram import filters
2022-12-27 13:36:54 +01:00
from pyrogram.types import Message
from pyrogram.client import Client
2023-01-05 13:08:08 +01:00
from modules.utils import configGet, jsonSave, locale, logWrite, should_quote
2022-12-11 19:52:02 +01:00
from modules.scheduled import scheduler
2022-12-27 18:46:17 +01:00
from modules import custom_filters
2022-12-05 18:49:51 +01:00
pid = getpid()
2023-01-05 13:08:08 +01:00
# Reboot command ===============================================================================================================
2023-01-03 21:46:16 +01:00
@app.on_message(custom_filters.enabled_general & ~filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]) & custom_filters.admin)
2022-12-27 13:36:54 +01:00
async def cmd_kill(app: Client, msg: Message):
2022-12-05 18:49:51 +01:00
2022-12-27 18:46:17 +01: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 13:08:08 +01:00
makedirs(configGet("cache", "locations"), exist_ok=True)
jsonSave({"timestamp": time()}, path.join(configGet("cache", "locations"), "shutdown_time"))
2022-12-27 18:46:17 +01:00
exit()
2022-12-05 18:49:51 +01:00
# ==============================================================================================================================