Ограничение по Telegram user_id

This commit is contained in:
Sergey 2021-02-23 21:29:00 +03:00
parent b7ad7c5e47
commit 68458e0a1a
2 changed files with 6 additions and 0 deletions

View File

@ -1,5 +1,7 @@
import os
ALLOWED_USER_IDS = os.environ.get('ALLOWED_USER_IDS', '')
DATABASE_USER = os.environ.get('POSTGRES_USER', 'postgres')
DATABASE_PASSWORD = os.environ.get('POSTGRES_PASSWORD', 'postgres')
DATABASE_HOST = os.environ.get('DATABASE_HOST', 'db')

View File

@ -560,6 +560,10 @@ async def search_callback(call: types.CallbackQuery):
@dp.message_handler(commands=['start'])
async def send_welcome(msg: types.Message):
if ALLOWED_USER_IDS:
if str(msg.from_user.id) not in ALLOWED_USER_IDS.replace(' ','').split(','):
await msg.reply('⛔️ Бот недоступен для Вашего аккаунта.')
return
user, created = await update_user_info(msg.from_user)
tgchat, tgchat_created = await update_chat_info(msg.chat)
if not tgchat: