This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
TelegramPoster/plugins/callbacks/shutdown.py

26 lines
667 B
Python
Raw Normal View History

2023-06-21 17:39:33 +03:00
from os import makedirs, path
2023-03-20 14:55:42 +02:00
from time import time
2023-06-21 17:39:33 +03:00
from libbot import config_get, json_write
2023-03-20 14:55:42 +02:00
from pyrogram import filters
2023-06-21 17:39:33 +03:00
from pyrogram.client import Client
2023-03-20 14:55:42 +02:00
from pyrogram.types import CallbackQuery
2023-06-21 17:39:33 +03:00
from classes.pyroclient import PyroClient
@Client.on_callback_query(filters.regex("shutdown"))
async def callback_query_nothing(app: PyroClient, clb: CallbackQuery):
if clb.from_user.id not in app.admins:
return
await clb.answer()
makedirs(await config_get("cache", "locations"), exist_ok=True)
await json_write(
{"timestamp": time()},
path.join(await config_get("cache", "locations"), "shutdown_time"),
)
2023-03-20 14:55:42 +02:00
2023-06-21 17:39:33 +03:00
exit()