Replace AI status message with emoji reactions

Instead of sending/editing a verbose status message, now reacts to the
command message: ⏳ while processing, ✅ on success, ❌ on error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 15:19:14 +02:00
parent e4e47c4649
commit 65088c2fdc

View File

@@ -309,26 +309,14 @@ async def ai(ctx: "CommandContext") -> None:
await ctx.reply(str(exc))
return
status = await ctx.reply(
"\n".join(
[
"⏳ AI request started",
f"model: {selected_alias}",
f"context: {invocation.context_messages} message(s)",
"tools: understand_image"
if invocation.use_image_understanding
else "tools: none",
f"prompt: {invocation.prompt[:200]}{'...' if len(invocation.prompt) > 200 else ''}",
]
)
)
async def _progress(text: str) -> None:
async def _react(emoji: str | None) -> None:
try:
await status.edit_text(text)
await ctx.client.send_reaction(ctx.message.chat.id, ctx.message.id, emoji=emoji)
except Exception:
pass
await _react("⏳")
try:
response = await ai_service.generate(
ctx,
@@ -338,16 +326,11 @@ async def ai(ctx: "CommandContext") -> None:
use_image_understanding=invocation.use_image_understanding,
prompt=invocation.prompt,
),
progress=_progress,
)
except (RuntimeError, ValueError) as exc:
await _progress(f"❌ {exc}")
await _react("❌")
await ctx.reply(str(exc))
return
final_text = f"✅\n{response.text}"
if len(final_text) <= 3900:
await _progress(final_text)
return
await _progress("✅ Response ready")
await _react("✅")
await _reply_long(ctx, response.text)