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

17 lines
564 B
Python
Raw Normal View History

2023-11-05 22:02:58 +05:30
from pyrogram import Client
from pyrogram.types import Message, CallbackQuery
from typing import Union, Callable
from functools import wraps
from bot.config import Telegram
def verify_user(func: Callable):
@wraps(func)
async def decorator(client: Client, update: Union[Message, CallbackQuery]):
2023-11-07 14:53:08 +05:30
chat_id = str(update.from_user.id if update.from_user else update.chat.id)
2023-11-05 22:02:58 +05:30
2023-11-07 14:53:08 +05:30
if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
2023-11-05 22:02:58 +05:30
return await func(client, update)
2023-11-07 14:53:08 +05:30
return decorator