Files
FileStreamBot-Caduceus/bot/modules/decorators.py

26 lines
1.1 KiB
Python
Raw Normal View History

2024-11-20 15:29:44 +05:30
from hydrogram import Client
2024-11-24 16:27:07 +05:30
from hydrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
2024-11-20 15:29:44 +05:30
from typing import Union, Callable
2023-11-05 22:02:58 +05:30
from functools import wraps
from bot.config import Telegram
2024-11-24 16:27:07 +05:30
from bot.modules.static import *
2023-11-05 22:02:58 +05:30
2024-11-20 15:29:44 +05:30
def verify_user(func: Callable):
2023-11-05 22:02:58 +05:30
2024-11-20 15:29:44 +05:30
@wraps(func)
async def decorator(client: Client, update: Union[Message, CallbackQuery]):
chat_id = str(update.from_user.id if update.from_user else update.chat.id)
2023-11-13 11:51:16 +05:30
2024-11-20 15:29:44 +05:30
if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
return await func(client, update)
2024-11-24 16:27:07 +05:30
elif isinstance(update, CallbackQuery):
return await update.answer(UserNotInAllowedList, show_alert=True)
elif isinstance(update, Message):
return await update.reply(
text = UserNotInAllowedList,
quote = True,
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton('Deploy Own', url='https://github.com/TheCaduceus/FileStreamBot')]])
)
2024-11-20 15:29:44 +05:30
2023-11-07 14:53:08 +05:30
return decorator