Команда /id, изменения set_env
This commit is contained in:
parent
68458e0a1a
commit
259840b40e
@ -18,6 +18,7 @@ __pycache__
|
|||||||
# Environment
|
# Environment
|
||||||
*.env
|
*.env
|
||||||
env_file
|
env_file
|
||||||
|
setenv.py
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
docker-compose*.yml
|
docker-compose*.yml
|
||||||
|
@ -8,6 +8,7 @@ POSTGRES_DB=tgvkbot
|
|||||||
POSTGRES_PASSWORD=postgres
|
POSTGRES_PASSWORD=postgres
|
||||||
BOT_TOKEN=%(tg_token)s
|
BOT_TOKEN=%(tg_token)s
|
||||||
VK_APP_ID=%(vk_app_id)s
|
VK_APP_ID=%(vk_app_id)s
|
||||||
|
ALLOWED_USER_IDS=%(allowed_user_ids)s
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -55,9 +56,9 @@ def set_env():
|
|||||||
break
|
break
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
print('❌ VK APP ID неверный, попробуйте снова!')
|
print('❌ VK APP ID неверный, попробуйте снова!')
|
||||||
|
|
||||||
with open('env_file', 'w') as env_file:
|
with open('env_file', 'w') as env_file:
|
||||||
env_file.write(ENV_FILE_TEMPLATE % {'tg_token': tg_token, 'vk_app_id': vk_app_id or VK_APP_ID})
|
env_file.write(ENV_FILE_TEMPLATE % {'tg_token': tg_token, 'vk_app_id': vk_app_id or VK_APP_ID}, 'allowed_user_ids': '')
|
||||||
|
|
||||||
print('✅ Успешно!')
|
print('✅ Успешно!')
|
||||||
|
|
@ -562,7 +562,7 @@ async def search_callback(call: types.CallbackQuery):
|
|||||||
async def send_welcome(msg: types.Message):
|
async def send_welcome(msg: types.Message):
|
||||||
if ALLOWED_USER_IDS:
|
if ALLOWED_USER_IDS:
|
||||||
if str(msg.from_user.id) not in ALLOWED_USER_IDS.replace(' ','').split(','):
|
if str(msg.from_user.id) not in ALLOWED_USER_IDS.replace(' ','').split(','):
|
||||||
await msg.reply('⛔️ Бот недоступен для Вашего аккаунта.')
|
await msg.reply('⛔️ Бот недоступен для Вашего аккаунта.\nУзнать Telegram ID - /id')
|
||||||
return
|
return
|
||||||
user, created = await update_user_info(msg.from_user)
|
user, created = await update_user_info(msg.from_user)
|
||||||
tgchat, tgchat_created = await update_chat_info(msg.chat)
|
tgchat, tgchat_created = await update_chat_info(msg.chat)
|
||||||
@ -697,10 +697,15 @@ async def help_command(msg: types.Message):
|
|||||||
'/search /s - Поиск по диалогам\n' \
|
'/search /s - Поиск по диалогам\n' \
|
||||||
'/chat - Список связанных чатов с диалогами ВКонтакте, привязать чат к диалогу можно добавив бота в группу\n' \
|
'/chat - Список связанных чатов с диалогами ВКонтакте, привязать чат к диалогу можно добавив бота в группу\n' \
|
||||||
'/stop - Выход из ВКонтакте\n' \
|
'/stop - Выход из ВКонтакте\n' \
|
||||||
'/help - Помощь'
|
'/help - Помощь' \
|
||||||
|
'/id - Узнать Telegram ID'
|
||||||
|
|
||||||
await bot.send_message(msg.chat.id, HELP_MESSAGE, parse_mode=ParseMode.HTML)
|
await bot.send_message(msg.chat.id, HELP_MESSAGE, parse_mode=ParseMode.HTML)
|
||||||
|
|
||||||
|
@dp.message_handler(commands=['id'])
|
||||||
|
async def id_command(msg: types.Message):
|
||||||
|
user, created = await update_user_info(msg.from_user)
|
||||||
|
await bot.send_message(msg.chat.id, 'Ваш ID: <code>{}</code>'.format(msg.from_user.id), parse_mode=ParseMode.HTML)
|
||||||
|
|
||||||
@dp.message_handler(content_types=['text'])
|
@dp.message_handler(content_types=['text'])
|
||||||
async def handle_text(msg: types.Message):
|
async def handle_text(msg: types.Message):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user