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/commands/general.py

46 lines
1.3 KiB
Python
Raw Normal View History

2023-06-21 17:39:33 +03:00
from os import makedirs
from pathlib import Path
2023-03-20 14:55:42 +02:00
from time import time
2023-02-14 12:38:54 +02:00
2023-06-21 17:39:33 +03:00
from libbot import json_write
2023-01-10 13:52:44 +02:00
from pyrogram import filters
2023-06-21 17:39:33 +03:00
from pyrogram.client import Client
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
2023-02-14 12:38:54 +02:00
2023-06-21 17:39:33 +03:00
from classes.pyroclient import PyroClient
from modules.utils import USERS_WITH_CONTEXT
2023-01-10 13:52:44 +02:00
2023-02-14 12:38:54 +02:00
2023-06-21 17:39:33 +03:00
@Client.on_message(
~filters.scheduled & filters.command(["shutdown"], prefixes=["", "/"])
)
async def cmd_kill(app: PyroClient, msg: Message):
if msg.from_user.id not in app.admins:
return
if len(USERS_WITH_CONTEXT) > 0:
await msg.reply_text(
app._("shutdown_confirm", "message").format(len(USERS_WITH_CONTEXT)),
reply_markup=InlineKeyboardMarkup(
[
2023-03-20 14:55:42 +02:00
[
2023-06-21 17:39:33 +03:00
InlineKeyboardButton(
app._(
"shutdown", "button", locale=msg.from_user.language_code
),
callback_data="shutdown",
)
2023-03-20 14:55:42 +02:00
]
2023-06-21 17:39:33 +03:00
]
2023-03-20 14:55:42 +02:00
),
)
2023-06-21 17:39:33 +03:00
return
makedirs(app.config["locations"]["cache"], exist_ok=True)
await json_write(
{"timestamp": time()},
Path(f"{app.config['locations']['cache']}/shutdown_time"),
)
exit()