40 lines
1.6 KiB
Python

from telegram import Update
from telegram.ext import ContextTypes
from models.session import set_state, SAISIE_MANUELLE_CHANTIER, set_data, ATTENTE_FAQ
from handlers import get_menu_keyboard, MENU_TEXT
from handlers.chantier import afficher_choix_chantier, handle_chantier_callback, FLOW_FIN, FLOW_SAV, FLOW_MAT
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.effective_message.reply_text(MENU_TEXT, reply_markup=get_menu_keyboard())
async def button_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
query = update.callback_query
await query.answer()
user_id = query.from_user.id
if query.data == "fin":
await afficher_choix_chantier(query, FLOW_FIN)
elif query.data == "sav":
await afficher_choix_chantier(query, FLOW_SAV)
elif query.data == "materiel":
await afficher_choix_chantier(query, FLOW_MAT)
elif query.data.startswith("chantier:"):
await handle_chantier_callback(query, user_id)
elif query.data == "faq":
set_state(user_id, ATTENTE_FAQ)
await query.edit_message_text(
"📚 *FAQ / Diagnostic*\n\nDécris ton problème :",
parse_mode="Markdown",
)
elif query.data.startswith("chantier_manuel:"):
_, flow = query.data.split(":", 1)
set_data(user_id, "flow", flow)
set_state(user_id, SAISIE_MANUELLE_CHANTIER)
await query.edit_message_text(
"✏️ *Nouveau chantier*\n\nEntrez le nom :\n`NOM_Ville`\n\n"
"Exemple : `Müller_Strasbourg`",
parse_mode="Markdown",
)