v1.8.1: fix consent flow — split-based word matching, refuse words before quick_intent, operator handler, plain text phones, clarify_intent post-processing

This commit is contained in:
2026-06-01 19:54:11 +03:00
parent cc87bcf72c
commit a64a274829
5 changed files with 142 additions and 25 deletions
+13 -1
View File
@@ -38,6 +38,18 @@ async def handle_contact_received(user_id: int, conv_id: int, contact_text: str)
async def handle_manual_contact(user_id: int, conv_id: int, text: str) -> None:
text = text.strip()
text_lower = text.lower()
refuse_words = ["нет", "не хочу", "отмена", "отказ", "no", "cancel"]
if any(w in text_lower for w in refuse_words):
async with async_session() as db:
conv = await db.get(BotConversation, conv_id)
if conv:
conv.state = "consent_refused"
await db.commit()
from app.handlers.consent import handle_refused_again
await handle_refused_again(user_id, conv_id, text)
return
if PHONE_PATTERN.match(text) or EMAIL_PATTERN.match(text):
await handle_contact_received(user_id, conv_id, text)
@@ -45,7 +57,7 @@ async def handle_manual_contact(user_id: int, conv_id: int, text: str) -> None:
await max_api.send_message(
user_id,
"Пожалуйста, введите корректный номер телефона (например, +7 (861) 203-33-30) "
"или адрес электронной почты.",
"или адрес электронной почты. Или напишите «Отмена» чтобы вернуться назад.",
)