30 lines
1017 B
Python
30 lines
1017 B
Python
from os import getpid, makedirs, path
|
|
from time import time
|
|
from modules.app import app
|
|
from pyrogram import filters
|
|
from pyrogram.types import CallbackQuery
|
|
from classes.poster_client import PosterClient
|
|
from modules.scheduler import scheduler
|
|
from modules.logger import logWrite
|
|
from modules.utils import configGet, jsonSave, locale
|
|
|
|
|
|
@app.on_callback_query(filters.regex("shutdown"))
|
|
async def callback_query_nothing(app: PosterClient, clb: CallbackQuery):
|
|
if clb.from_user.id in app.admins:
|
|
pid = getpid()
|
|
logWrite(f"Shutting down bot with pid {pid}")
|
|
await clb.answer()
|
|
await clb.message.reply_text(
|
|
locale("shutdown", "message", locale=clb.from_user.language_code).format(
|
|
pid
|
|
),
|
|
)
|
|
scheduler.shutdown()
|
|
makedirs(configGet("cache", "locations"), exist_ok=True)
|
|
jsonSave(
|
|
{"timestamp": time()},
|
|
path.join(configGet("cache", "locations"), "shutdown_time"),
|
|
)
|
|
exit()
|