From 84f4e25636e7064f0587f0237539d3cc1a6a02d8 Mon Sep 17 00:00:00 2001 From: "Dr.Caduceus" Date: Mon, 13 Nov 2023 11:51:16 +0530 Subject: [PATCH] Bump to v1.5 --- bot/modules/decorators.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/bot/modules/decorators.py b/bot/modules/decorators.py index 3c24daa..cd8d7b9 100644 --- a/bot/modules/decorators.py +++ b/bot/modules/decorators.py @@ -1,16 +1,22 @@ -from pyrogram import Client -from pyrogram.types import Message, CallbackQuery -from typing import Union, Callable +from telethon.events import NewMessage, CallbackQuery +from telethon.tl.custom import Message +from typing import Callable from functools import wraps from bot.config import Telegram +from bot.modules.static import * -def verify_user(func: Callable): +def verify_user(private: bool = False): - @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) + def decorator(func: Callable): + @wraps(func) + async def wrapper(update: NewMessage.Event | CallbackQuery.Event): + if private and not update.is_private: + return - if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS: - return await func(client, update) - + chat_id = str(update.chat_id) + + if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS: + return await func(update) + + return wrapper return decorator