- Author: Daniel Li
- Copyright © Daniel Li. All rights reserved.
Push messages to group chats or private chats via an independent Telegram Bot, without relying on OpenClaw's telegram channel configuration.
Bot Configuration
| Bot | Username | Token Path | Purpose |
|---|---|---|---|
| NewsRobot | @fkkanfnnfbot | pass show tokens/telegram-newsrobot |
DailyNews group message push |
| Main Bot | @DanielLi_smartest_Bot | OpenClaw built-in | Private chat interaction |
Push Targets
| Group/Target | Chat ID | Push Bot | Description |
|---|---|---|---|
| DailyNews group | -1003824568687 |
NewsRobot | News, skill collection, study reports, etc. |
| Daniel private chat | 8518085684 |
Main Bot (message tool) | Alerts, personal notifications |
Push Rules
Core principle: All pushes to the DailyNews group must go through NewsRobot; do not use the message tool.
| Cron Task | Push Target | Push Method | Description |
|---|---|---|---|
| Tech Daily push | DailyNews group | news_push.py(built-in NewsRobot) |
8:00/13:00/19:00 |
| Xiao a skill collection | DailyNews group | newsbot_send.py |
Every hour |
| Xiao a nighttime self-learning | DailyNews group + Daniel private chat | For DailyNews usenewsbot_send.py, for private chat usemessage tool |
1:00-6:30 every 30 min, 06:30 push summary report |
| Xiao a team daily report summary | Daniel private chat | message tool | 23:00 |
| API usage and balance statistics | Daniel private chat | announce/message tool | 2/8/14/20 o'clock |
| A-share fund real-time monitoring | Daniel private chat | announce/message tool | Workdays 10/13/15 o'clock |
| Healthcare enterprise financing monitoring | Daniel private chat | announce/message tool | Daily at 9:00 |
Push Scripts
1. newsbot_send.py (recommended)
General-purpose NewsRobot push script; all pushes to the DailyNews group should use this:
# 直接传参
python3 ~/clawd/scripts/newsbot_send.py "消息内容"
# 管道传入
echo "消息内容" | python3 ~/clawd/scripts/newsbot_send.py
Path: ~/clawd/scripts/newsbot_send.py
2. news_push.py
Dedicated tech news script, with built-in news scraping + NewsRobot push:
python3 ~/clawd/scripts/news_push.py
Path: ~/clawd/scripts/news_push.py
3. Shell shortcut
# 快速推送到DailyNews群
~/clawd/skills/telegram-push/telegram-push.sh "消息内容"
4. Python direct call
import subprocess
def push_to_dailynews(text):
subprocess.run(['python3', '/home/aa/clawd/scripts/newsbot_send.py', text])
Telegram API Reference
Send text
TOKEN=$(pass show tokens/telegram-newsrobot)
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d '{"chat_id": -1003824568687, "text": "消息", "parse_mode": "HTML"}'
Send photo
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendPhoto" \
-H "Content-Type: application/json" \
-d '{"chat_id": -1003824568687, "photo": "URL", "caption": "说明"}'
Send message with buttons
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": -1003824568687,
"text": "消息",
"reply_markup": {"inline_keyboard": [[{"text": "按钮", "url": "https://..."}]]}
}'
Add New Group
- Add @fkkanfnnfbot to the target group
- Send a message in the group
- Get chat_id:
curl -s "https://api.telegram.org/bot$(pass show tokens/telegram-newsrobot)/getUpdates" | python3 -c "import json,sys; d=json.load(sys.stdin); [print(r['message']['chat']) for r in d.get('result',[]) if 'message' in r]" - Update the push target table in this document
- If a new script is needed, refer to
newsbot_send.pymodifyCHAT_ID
Notes
- Supergroup chat_id starts with
-100starts with - Sending rate limit: about 20 messages per minute per group
- HTML parse_mode supports:
<b>,<i>,<code>,<pre>,<a href=""> - Never hardcode keys, uniformly use
pass show tokens/telegram-newsrobot
Error Handling
| Error | Cause | Solution |
|---|---|---|
| chat not found | Bot not added to group | Add the bot to the group |
| 429 Too Many Requests | Sending too frequently | Wait retry_after seconds and retry |
| bot was blocked | User blocked the bot | User must unblock |
| Unauthorized | Invalid token | Check pass show tokens/telegram-newsrobot |