Dr.Caduceus commited on
Commit
84f4e25
·
unverified ·
1 Parent(s): 92247f7

Bump to v1.5

Browse files
Files changed (1) hide show
  1. bot/modules/decorators.py +16 -10
bot/modules/decorators.py CHANGED
@@ -1,16 +1,22 @@
1
- from pyrogram import Client
2
- from pyrogram.types import Message, CallbackQuery
3
- from typing import Union, Callable
4
  from functools import wraps
5
  from bot.config import Telegram
 
6
 
7
- def verify_user(func: Callable):
8
 
9
- @wraps(func)
10
- async def decorator(client: Client, update: Union[Message, CallbackQuery]):
11
- chat_id = str(update.from_user.id if update.from_user else update.chat.id)
 
 
12
 
13
- if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
14
- return await func(client, update)
15
-
 
 
 
16
  return decorator
 
1
+ from telethon.events import NewMessage, CallbackQuery
2
+ from telethon.tl.custom import Message
3
+ from typing import Callable
4
  from functools import wraps
5
  from bot.config import Telegram
6
+ from bot.modules.static import *
7
 
8
+ def verify_user(private: bool = False):
9
 
10
+ def decorator(func: Callable):
11
+ @wraps(func)
12
+ async def wrapper(update: NewMessage.Event | CallbackQuery.Event):
13
+ if private and not update.is_private:
14
+ return
15
 
16
+ chat_id = str(update.chat_id)
17
+
18
+ if not Telegram.ALLOWED_USER_IDS or chat_id in Telegram.ALLOWED_USER_IDS:
19
+ return await func(update)
20
+
21
+ return wrapper
22
  return decorator