32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from telegram import Update, ForceReply
|
|
from telegram.ext import ContextTypes
|
|
from models.session import set_state, MENU
|
|
from handlers import get_menu_keyboard, MENU_TEXT
|
|
from services.faq_service import faq_service
|
|
|
|
|
|
async def handle_faq(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
msg = update.message
|
|
question = (msg.text or "").strip()
|
|
if not question:
|
|
await msg.reply_text("❌ Merci d'écrire ta question.")
|
|
return
|
|
thinking = await msg.reply_text("🔍 Recherche en cours...")
|
|
reponse = await faq_service.repondre(question)
|
|
await thinking.edit_text(reponse)
|
|
set_state(msg.from_user.id, MENU)
|
|
await msg.reply_text(MENU_TEXT, reply_markup=get_menu_keyboard())
|
|
|
|
|
|
async def cmd_faq(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
if not context.args:
|
|
await update.message.reply_text(
|
|
"📚 FAQ ETM\n\nPose ta question :\n/faq Fronius erreur 567\n/faq PAC ne démarre plus",
|
|
reply_markup=ForceReply(selective=True),
|
|
)
|
|
return
|
|
question = " ".join(context.args)
|
|
msg = await update.message.reply_text("🔍 Recherche en cours...")
|
|
reponse = await faq_service.repondre(question)
|
|
await msg.edit_text(reponse)
|