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: Implement Telegram draft/progress messages (streaming)
Sergio Sánchez Vallés102b9716ed15
diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.pyindex c290535fd..5f739e5fa 100644--- a/nanobot/channels/telegram.py+++ b/nanobot/channels/telegram.py@@ -269,23 +269,41 @@ class TelegramChannel(BaseChannel):# Send text contentif msg.content and msg.content != "[empty message]":+ is_progress = msg.metadata.get("_progress", False)+ draft_id = msg.metadata.get("message_id")+for chunk in _split_message(msg.content):try:html = _markdown_to_telegram_html(chunk)- await self._app.bot.send_message(- chat_id=chat_id,- text=html,- parse_mode="HTML",- reply_parameters=reply_params- )- except Exception as e:- logger.warning("HTML parse failed, falling back to plain text: {}", e)- try:+ if is_progress and draft_id:+ await self._app.bot.send_message_draft(+ chat_id=chat_id,+ draft_id=draft_id,+ text=html,+ parse_mode="HTML"+ )+ else:await self._app.bot.send_message(chat_id=chat_id,- text=chunk,+ text=html,+ parse_mode="HTML",reply_parameters=reply_params)+ except Exception as e:+ logger.warning("HTML parse failed (or draft send failed), falling back to plain text: {}", e)+ try:+ if is_progress and draft_id:+ await self._app.bot.send_message_draft(+ chat_id=chat_id,+ draft_id=draft_id,+ text=chunk+ )+ else:+ await self._app.bot.send_message(+ chat_id=chat_id,+ text=chunk,+ reply_parameters=reply_params+ )except Exception as e2:logger.error("Error sending Telegram message: {}", e2)diff --git a/pyproject.toml b/pyproject.tomlindex a22053c49..42f6194c3 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -30,7 +30,7 @@ dependencies = ["rich>=14.0.0,<15.0.0","croniter>=6.0.0,<7.0.0","dingtalk-stream>=0.24.0,<1.0.0",- "python-telegram-bot[socks]>=22.0,<23.0",+ "python-telegram-bot[socks] @ git+https://github.com/python-telegram-bot/python-telegram-bot.git@master","lark-oapi>=1.5.0,<2.0.0","socksio>=1.0.0,<2.0.0","python-socketio>=5.16.0,<6.0.0",@@ -63,6 +63,9 @@ nanobot = "nanobot.cli.commands:app"requires = ["hatchling"]build-backend = "hatchling.build"+[tool.hatch.metadata]+allow-direct-references = true+[tool.hatch.build.targets.wheel]packages = ["nanobot"]