Reorganize the project for better compatibility with unittests

This commit is contained in:
Roman Krček
2024-10-13 11:22:37 +02:00
parent 3c34c0f947
commit 725cf30319
5 changed files with 199 additions and 151 deletions

View File

@@ -0,0 +1,18 @@
import os
from functools import wraps
# Comma separated list of Telegram IDs that this bot will respond to
allowed_ids_raw = os.getenv("ALLOWED_IDS", "")
allowed_ids = allowed_ids_raw.split(",")
print(allowed_ids_raw)
print(allowed_ids)
def protected(func):
@wraps(func)
async def wrapper(client, message):
if message.from_user.id not in allowed_ids:
return await message.reply_text("You are not on the list!")
return await func(client, message)
return wrapper