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)) await ctx.reply(str(exc))
return return
status = await ctx.reply( async def _react(emoji: str | None) -> None:
"\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:
try: try:
await status.edit_text(text) await ctx.client.send_reaction(ctx.message.chat.id, ctx.message.id, emoji=emoji)
except Exception: except Exception:
pass pass
await _react("⏳")
try: try:
response = await ai_service.generate( response = await ai_service.generate(
ctx, ctx,
@@ -338,16 +326,11 @@ async def ai(ctx: "CommandContext") -> None:
use_image_understanding=invocation.use_image_understanding, use_image_understanding=invocation.use_image_understanding,
prompt=invocation.prompt, prompt=invocation.prompt,
), ),
progress=_progress,
) )
except (RuntimeError, ValueError) as exc: except (RuntimeError, ValueError) as exc:
await _progress(f"❌ {exc}") await _react("❌")
await ctx.reply(str(exc))
return return
final_text = f"✅\n{response.text}" await _react("✅")
if len(final_text) <= 3900:
await _progress(final_text)
return
await _progress("✅ Response ready")
await _reply_long(ctx, response.text) await _reply_long(ctx, response.text)