Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(telegram): add react_emoji config for incoming messages
flobo39a2b1a3f1a34
diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.pyindex 850e09c0f..04cc89cc2 100644--- a/nanobot/channels/telegram.py+++ b/nanobot/channels/telegram.py@@ -11,7 +11,7 @@ from typing import Any, Literalfrom loguru import loggerfrom pydantic import Field-from telegram import BotCommand, ReplyParameters, Update+from telegram import BotCommand, ReactionTypeEmoji, ReplyParameters, Updatefrom telegram.error import TimedOutfrom telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filtersfrom telegram.request import HTTPXRequest@@ -173,6 +173,7 @@ class TelegramConfig(Base):allow_from: list[str] = Field(default_factory=list)proxy: str | None = Nonereply_to_message: bool = False+ react_emoji: str = "👀"group_policy: Literal["open", "mention"] = "mention"connection_pool_size: int = 32pool_timeout: float = 5.0@@ -812,6 +813,7 @@ class TelegramChannel(BaseChannel):"session_key": session_key,}self._start_typing(str_chat_id)+ await self._add_reaction(str_chat_id, message.message_id, self.config.react_emoji)buf = self._media_group_buffers[key]if content and content != "[empty message]":buf["contents"].append(content)@@ -822,6 +824,7 @@ class TelegramChannel(BaseChannel):# Start typing indicator before processingself._start_typing(str_chat_id)+ await self._add_reaction(str_chat_id, message.message_id, self.config.react_emoji)# Forward to the message busawait self._handle_message(@@ -861,6 +864,19 @@ class TelegramChannel(BaseChannel):if task and not task.done():task.cancel()+ async def _add_reaction(self, chat_id: str, message_id: int, emoji: str) -> None:+ """Add emoji reaction to a message (best-effort, non-blocking)."""+ if not self._app or not emoji:+ return+ try:+ await self._app.bot.set_message_reaction(+ chat_id=int(chat_id),+ message_id=message_id,+ reaction=[ReactionTypeEmoji(emoji=emoji)],+ )+ except Exception as e:+ logger.debug("Telegram reaction failed: {}", e)+async def _typing_loop(self, chat_id: str) -> None:"""Repeatedly send 'typing' action until cancelled."""try: