telegram-mcp-server 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {telegram_mcp_server-0.2.2/telegram_mcp_server.egg-info → telegram_mcp_server-0.2.3}/PKG-INFO +1 -1
  2. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/pyproject.toml +1 -1
  3. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/server.py +58 -17
  4. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3/telegram_mcp_server.egg-info}/PKG-INFO +1 -1
  5. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/LICENSE +0 -0
  6. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/MANIFEST.in +0 -0
  7. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/README.md +0 -0
  8. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/requirements.txt +0 -0
  9. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/setup.cfg +0 -0
  10. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/__init__.py +0 -0
  11. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/__main__.py +0 -0
  12. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/bot.py +0 -0
  13. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/cli.py +0 -0
  14. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/config.py +0 -0
  15. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/message_queue.py +0 -0
  16. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/session.py +0 -0
  17. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/SOURCES.txt +0 -0
  18. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/dependency_links.txt +0 -0
  19. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/entry_points.txt +0 -0
  20. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/requires.txt +0 -0
  21. {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telegram-mcp-server
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Remote control Claude Code via Telegram - MCP Server with Dynamic Buttons
5
5
  Author-email: Ray Volcy <volycu@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "telegram-mcp-server"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Remote control Claude Code via Telegram - MCP Server with Dynamic Buttons"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -92,17 +92,20 @@ async def send_telegram_message(chat_id: str, message: str, parse_mode: str = "M
92
92
  async with httpx.AsyncClient() as client:
93
93
  response = await client.post(url, json=payload, timeout=10.0)
94
94
  response.raise_for_status()
95
- except Exception as e:
96
- logger.warning(f"Failed to send with {parse_mode}, retrying as plain text: {e}")
97
- try:
98
- # Retry without parse_mode
95
+ except httpx.HTTPStatusError as e:
96
+ if e.response.status_code == 400 and parse_mode:
97
+ # Markdown parsing failed, retry without parse_mode
98
+ logger.warning(f"Markdown parsing failed (400 Bad Request), retrying as plain text")
99
99
  payload.pop("parse_mode", None)
100
100
  async with httpx.AsyncClient() as client:
101
101
  response = await client.post(url, json=payload, timeout=10.0)
102
102
  response.raise_for_status()
103
- except Exception as e2:
104
- logger.error(f"Failed to send Telegram message: {e2}")
103
+ else:
104
+ logger.error(f"Failed to send Telegram message: {e}")
105
105
  raise
106
+ except Exception as e:
107
+ logger.error(f"Failed to send Telegram message: {e}")
108
+ raise
106
109
 
107
110
 
108
111
  def get_poll_interval(elapsed_seconds: float) -> int:
@@ -129,9 +132,14 @@ async def list_tools() -> list[Tool]:
129
132
  Tool(
130
133
  name="telegram_notify",
131
134
  description="""
132
- 发送简单通知到 Telegram(基础版本)
133
-
134
- ⚠️ 推荐使用 telegram_notify_with_actions 代替此工具
135
+ ⚠️ 这是 Telegram MCP Server 的通知工具
136
+ 用于向用户的 Telegram Bot 发送任务进度通知
137
+
138
+ ❌ 这不是通用的 Telegram 消息发送工具
139
+ ❌ 不能发送消息到任意 Telegram 用户或群组
140
+ ✅ 只能发送通知到配置的 Telegram Bot(用户会在 Telegram 中收到)
141
+
142
+ 💡 推荐使用 telegram_notify_with_actions 代替此工具
135
143
  telegram_notify_with_actions 提供动态按钮,用户体验更好
136
144
 
137
145
  此工具适用于:
@@ -178,6 +186,13 @@ async def list_tools() -> list[Tool]:
178
186
  description="""
179
187
  ⭐ 推荐:发送带有动态操作按钮的智能通知到 Telegram
180
188
 
189
+ ⚠️ 这是 Telegram MCP Server 的通知工具(增强版)
190
+ 用于向用户的 Telegram Bot 发送任务进度通知,并提供智能操作建议
191
+
192
+ ❌ 这不是通用的 Telegram 消息发送工具
193
+ ❌ 不能发送消息到任意 Telegram 用户或群组
194
+ ✅ 只能发送通知到配置的 Telegram Bot(用户会在 Telegram 中收到)
195
+
181
196
  这是 telegram_notify 的增强版本,可以根据当前情况为用户提供智能的下一步操作建议。
182
197
 
183
198
  优势:
@@ -529,16 +544,31 @@ async def list_tools() -> list[Tool]:
529
544
  Tool(
530
545
  name="telegram_unattended_mode",
531
546
  description="""
532
- 进入无人值守模式 - 智能远程任务循环
547
+ ⚠️ 这是 Telegram MCP Server 的无人值守模式工具
548
+ 用于等待用户通过 Telegram Bot 发送的下一步指令
549
+
550
+ ❌ 这不是通用的 Telegram 操作工具
551
+ ❌ 不用于发送 Telegram 消息(使用 telegram_notify 系列工具)
552
+ ❌ 不用于管理 Telegram 群组或频道
553
+
554
+ ✅ 正确用途:远程任务循环 - 等待用户通过 Telegram 发送指令
533
555
 
534
556
  工作流程:
535
557
  1. 执行当前任务
536
- 2. 根据情况智能选择通知方式:
537
- - 默认:使用 telegram_notify 发送总结
538
- - 遇到关键问题/错误:使用 telegram_send_code 展示问题代码
539
- - 用户明确要求:使用 telegram_send_file 发送文件
540
- 3. 调用 telegram_unattended_mode 等待下一步指令(静默等待,不发送额外提示)
558
+ 2. 使用 telegram_notify_with_actions 发送结果(带智能按钮)
559
+ 3. 调用 telegram_unattended_mode 等待用户通过 Telegram 发送的下一步指令
541
560
  4. 收到指令后执行,重复循环
561
+
562
+ 示例场景:
563
+ 用户说:"进入无人值守模式,任务:分析项目结构"
564
+
565
+ 你应该:
566
+ 1. 分析项目结构
567
+ 2. 调用 telegram_notify_with_actions 发送分析结果
568
+ 3. 调用 telegram_unattended_mode 等待下一步指令
569
+ 4. 用户在 Telegram 中发送"优化性能"
570
+ 5. 你收到指令,执行优化
571
+ 6. 重复步骤 2-5
542
572
 
543
573
  ⚠️ 重要:
544
574
  - 完成任务后必须调用通知工具发送结果
@@ -820,8 +850,19 @@ async def handle_telegram_notify_with_actions(session, arguments: dict) -> list[
820
850
  payload["reply_markup"] = {"inline_keyboard": keyboard}
821
851
 
822
852
  async with httpx.AsyncClient() as client:
823
- response = await client.post(url, json=payload, timeout=10.0)
824
- response.raise_for_status()
853
+ try:
854
+ # Try with Markdown first
855
+ response = await client.post(url, json=payload, timeout=10.0)
856
+ response.raise_for_status()
857
+ except httpx.HTTPStatusError as e:
858
+ if e.response.status_code == 400:
859
+ # Markdown parsing failed, retry without parse_mode
860
+ logger.warning(f"Markdown parsing failed, retrying as plain text")
861
+ payload.pop("parse_mode", None)
862
+ response = await client.post(url, json=payload, timeout=10.0)
863
+ response.raise_for_status()
864
+ else:
865
+ raise
825
866
 
826
867
  return [TextContent(
827
868
  type="text",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telegram-mcp-server
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Remote control Claude Code via Telegram - MCP Server with Dynamic Buttons
5
5
  Author-email: Ray Volcy <volycu@gmail.com>
6
6
  License: MIT