fix: send new message if edit_text fails silently in /process
Build & Deploy ResearchOwl / build-and-push (push) Successful in 7s
Build & Deploy ResearchOwl / build-and-push (push) Successful in 7s
If the bot restarted between sending the progress message and the completion callback, edit_text may fail silently (Conflict/stale ref). Store completion text and reply_text as fallback so the user always sees the result. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-8
@@ -465,21 +465,28 @@ async def cmd_process(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
processor = ContentProcessor(db, ollama)
|
||||
|
||||
completion_text = None
|
||||
|
||||
async def proc_progress(total_chunks, total_words):
|
||||
nonlocal completion_text
|
||||
completion_text = (
|
||||
f"🧠 *Processing complete!*\n"
|
||||
f"• Chunks stored: `{total_chunks}`\n"
|
||||
f"• Words researched: `{total_words:,}`\n\n"
|
||||
f"Ready! Use `/generate podcast|blog|report|thread`"
|
||||
)
|
||||
try:
|
||||
await msg.edit_text(
|
||||
f"🧠 *Processing complete!*\n"
|
||||
f"• Chunks stored: `{total_chunks}`\n"
|
||||
f"• Words researched: `{total_words:,}`\n\n"
|
||||
f"Ready! Use `/generate podcast|blog|report|thread`\n"
|
||||
f"_If 0 chunks: set `QUALITY_THRESHOLD=0.3` or `0` and retry_",
|
||||
parse_mode=ParseMode.MARKDOWN
|
||||
)
|
||||
await msg.edit_text(completion_text, parse_mode=ParseMode.MARKDOWN)
|
||||
completion_text = None # sent, no need to resend
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
await processor.process_session(session_id, topic, proc_progress)
|
||||
|
||||
# Fallback: if edit_text failed silently, send a new message
|
||||
if completion_text:
|
||||
await update.message.reply_text(completion_text, parse_mode=ParseMode.MARKDOWN)
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Process command failed", error=str(e))
|
||||
await update.message.reply_text(f"❌ Processing failed: {str(e)[:200]}")
|
||||
|
||||
Reference in New Issue
Block a user