Files
Telegram-Downloader-Bot/telegram_downloader_bot/security.py
Roman Krček 3075743c5d
Some checks failed
Build Docker image / build (push) Has been skipped
Build Docker image / test (push) Failing after 2m41s
Fix linter issues and unittests
2024-10-13 21:18:18 +02:00

20 lines
664 B
Python

from functools import wraps
from telegram_downloader_bot.logger import log
from telegram_downloader_bot.settings import settings
def protected(func):
@wraps(func)
async def wrapper(client, message):
if int(message.from_user.id) not in settings.allowed_ids_list:
log.warning(
f"User with ID {message.from_user.id} attempted"
"to text this bot!")
log.info(
"Only users allowed are:"
f"{' '.join(settings.allowed_ids_list)}")
return await message.reply_text("You are not on the list!")
return await func(client, message)
return wrapper