17 lines
619 B
Python
17 lines
619 B
Python
import logging
|
|
|
|
|
|
from aiogram import types
|
|
|
|
from utils.db import AsyncSessionLocal, Whitelist
|
|
from sqlalchemy.future import select
|
|
|
|
async def is_whitelisted(message: types.message):
|
|
chat_id = message.chat.id
|
|
async with AsyncSessionLocal() as session:
|
|
stmt = select(Whitelist).filter_by(chat_id=chat_id)
|
|
result = await session.execute(stmt)
|
|
user = result.scalars().first()
|
|
if not user:
|
|
await message.answer("Вы не авторизованы для использования этого бота")
|
|
logging.info(f"Unauthorized access attempt by {chat_id}") |