- Implemented the initial version of the web interface. refactor: Begin Telegram bot refactoring - Started restructuring the bot’s code for better maintainability. chore: Migrate to Flask project structure - Reorganized the application to follow Flask's project structure. cleanup: Extensive code cleanup - Removed redundant code and improved readability. Signed-off-by: UdoChudo <stream@udochudo.ru>
42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
# app/bot/handlers/start.py
|
|
from telebot.types import Message, ReplyKeyboardMarkup, KeyboardButton
|
|
from app.bot.keyboards.main_menu import get_main_menu
|
|
|
|
def register_handlers(bot):
|
|
@bot.message_handler(commands=['start'])
|
|
def start_handler(message, data=None):
|
|
chat_id = message.chat.id
|
|
|
|
if data:
|
|
if data.get('user_verified'):
|
|
user = data['user']
|
|
bot.send_message(
|
|
chat_id,
|
|
f"👋 Привет, {user.user_email}!\nВыберите действие из меню:",
|
|
reply_markup=get_main_menu()
|
|
)
|
|
return
|
|
|
|
elif data.get('user_blocked'):
|
|
bot.send_message(
|
|
chat_id,
|
|
"🚫 Ваш аккаунт заблокирован.\n"
|
|
"Пожалуйста, обратитесь к администратору."
|
|
)
|
|
return
|
|
|
|
elif data.get('user_not_found'):
|
|
keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
|
|
keyboard.add(KeyboardButton("Регистрация"))
|
|
bot.send_message(
|
|
chat_id,
|
|
"👋 Добро пожаловать!\n\n"
|
|
"❗ Вы не зарегистрированы в системе.\n"
|
|
"Пожалуйста, нажмите кнопку ниже для регистрации.",
|
|
reply_markup=keyboard
|
|
)
|
|
return
|
|
|
|
# fallback
|
|
bot.send_message(chat_id, "Произошла ошибка. Попробуйте позже.")
|