Fix: удалить вызов get_mode() после удаления ChatMode

- Исправлена ошибка в handle_message
- Исправлена ошибка в process_text_as_message
- Бот теперь работает с голосовыми сообщениями

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad 2026-03-19 01:00:42 +08:00
parent 6b21889964
commit 490278f680
1 changed files with 5 additions and 7 deletions

View File

@ -434,24 +434,23 @@ async def handle_voice(update: Update, context: ContextTypes.DEFAULT_TYPE):
async def process_text_as_message(update: Update, context: ContextTypes.DEFAULT_TYPE, text: str):
"""Обработка распознанного текста как обычного сообщения"""
chat_id = update.effective_chat.id
mode = chat_state.get_mode(chat_id)
tool = get_selected_tool()
model = get_selected_model() if tool == "opencode" else None
# Проверяем не ждем ли мы email для XRay
if chat_state.get_xray_state(chat_id) == XRayState.WAITING_EMAIL:
email = text.strip()
await process_xray_email(update, context, email)
return
thinking_msg = await update.message.reply_text("🤔 Думаю...")
result, success = await orchestrator.ask(text, chat_id, tool, model, yolo=True)
text_result = result.strip() if result else ""
if not text_result:
text_result = "⚠️ Пустой ответ от модели."
text_result = text_result[:4096]
await thinking_msg.edit_text(text_result, parse_mode="Markdown")
@ -459,7 +458,6 @@ async def process_text_as_message(update: Update, context: ContextTypes.DEFAULT_
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
prompt = update.message.text
chat_id = update.effective_chat.id
mode = chat_state.get_mode(chat_id)
tool = get_selected_tool()
model = get_selected_model() if tool == "opencode" else None