Spaces:
Sleeping
Sleeping
Dr.Caduceus commited on
Bump to v1.5
Browse files- bot/modules/decorators.py +16 -10
bot/modules/decorators.py
CHANGED
|
@@ -1,16 +1,22 @@
|
|
| 1 |
-
from
|
| 2 |
-
from
|
| 3 |
-
from typing import
|
| 4 |
from functools import wraps
|
| 5 |
from bot.config import Telegram
|
|
|
|
| 6 |
|
| 7 |
-
def verify_user(
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 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
|