Files
FileStreamBot-Caduceus/bot/plugins/callback.py

32 lines
985 B
Python
Raw Normal View History

2024-11-20 15:29:44 +05:30
from hydrogram.types import CallbackQuery
2023-11-05 22:02:58 +05:30
from bot import TelegramBot
from bot.modules.decorators import verify_user
2023-11-13 11:52:40 +05:30
from bot.modules.static import *
2023-11-05 22:02:58 +05:30
from bot.modules.telegram import get_message
2024-11-20 15:29:44 +05:30
@TelegramBot.on_callback_query()
@verify_user
async def manage_callback(bot, q: CallbackQuery):
query = q.data
2023-11-13 11:52:40 +05:30
2024-11-20 15:29:44 +05:30
if query.startswith('rm_'):
sq = query.split('_')
2023-11-13 11:52:40 +05:30
2024-11-20 15:29:44 +05:30
if len(sq) != 3:
return await q.answer(InvalidQueryText, show_alert=True)
2023-11-13 11:52:40 +05:30
2024-11-20 15:29:44 +05:30
message = await get_message(int(sq[1]))
2023-11-05 22:02:58 +05:30
2024-11-20 15:29:44 +05:30
if not message:
return await q.answer(MessageNotExist, show_alert=True)
sc = message.caption.split('/')
2023-11-05 22:02:58 +05:30
2024-11-20 15:29:44 +05:30
if q.from_user.id != int(sc[1]) or sq[2] != sc[0]:
return await q.answer(InvalidQueryText, show_alert=True)
await message.delete()
await q.answer(LinkRevokedText, show_alert=True)
else:
await q.answer(InvalidQueryText, show_alert=True)