Download bot/modules/decorators.py from dimag69/tg-fs: direct link, hf CLI and curl.
- Browser
- Download file 609 Bytes
-
https://huggingface.co/spaces/dimag69/tg-fs/resolve/main/bot/modules/decorators.py
- Command line
-
hf download hf://spaces/dimag69/tg-fs/bot/modules/decorators.py
-
curl -L -o decorators.py https://huggingface.co/spaces/dimag69/tg-fs/resolve/main/bot/modules/decorators.py
609 Bytes
| from telethon.events import NewMessage, CallbackQuery | |
| from typing import Callable | |
| from functools import wraps | |
| from bot.config import Telegram | |
| def verify_user(private: bool = False): | |
| def decorator(func: Callable): | |
| async def wrapper(update: NewMessage.Event | CallbackQuery.Event): | |
| if private and not update.is_private: | |
| return | |
| 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 | |