tg-responder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesetg-responder — Telegram Communications Assistant
tg-responder — Telegram通讯助手
Review pending response drafts and manage the Telegram response queue.
审核待处理的回复草稿,管理Telegram回复队列。
Commands
命令
review — Approve pending drafts
review — 审核待处理草稿
Read the responder queue and present drafts for approval:
bash
python3 ~/.claude/skills/tg-responder/scripts/schema.py # ensure DB existsThen query the database:
sql
-- Pending drafts needing approval
SELECT o.id, o.chat_id, o.draft_text, o.draft_reason, o.source,
i.sender_name, i.text as original_text, i.urgency, i.category,
datetime(i.received_at, 'unixepoch') as received
FROM outbox o
JOIN inbox i ON o.inbox_id = i.id
WHERE o.status = 'draft'
ORDER BY
CASE i.urgency WHEN 'urgent' THEN 0 WHEN 'normal' THEN 1 ELSE 2 END,
o.created_at ASC;For each draft, present to the user:
- Original message — who sent it, when, what they said
- Draft response — the proposed reply
- Options: approve (send as-is), edit (modify then send), skip
To approve and send a draft:
- Update outbox:
UPDATE outbox SET status = 'approved', final_text = draft_text, approved_at = strftime('%s','now') WHERE id = ? - Send via telegram skill:
python3 ~/.claude/skills/telegram/scripts/telegram_fetch.py send --chat-id CHAT_ID --text "THE_TEXT" - Update outbox with sent status and message_id
To skip:
UPDATE outbox SET status = 'skipped', updated_at = strftime('%s','now') WHERE id = ?读取回复队列并展示待审核草稿:
bash
python3 ~/.claude/skills/tg-responder/scripts/schema.py # ensure DB exists随后查询数据库:
sql
-- Pending drafts needing approval
SELECT o.id, o.chat_id, o.draft_text, o.draft_reason, o.source,
i.sender_name, i.text as original_text, i.urgency, i.category,
datetime(i.received_at, 'unixepoch') as received
FROM outbox o
JOIN inbox i ON o.inbox_id = i.id
WHERE o.status = 'draft'
ORDER BY
CASE i.urgency WHEN 'urgent' THEN 0 WHEN 'normal' THEN 1 ELSE 2 END,
o.created_at ASC;针对每个草稿,向用户展示以下内容:
- 原始消息 — 发送人、发送时间、消息内容
- 回复草稿 — 拟回复内容
- 操作选项:批准(直接发送)、编辑(修改后发送)、跳过
批准并发送草稿的步骤:
- 更新发件箱:
UPDATE outbox SET status = 'approved', final_text = draft_text, approved_at = strftime('%s','now') WHERE id = ? - 通过Telegram技能发送:
python3 ~/.claude/skills/telegram/scripts/telegram_fetch.py send --chat-id CHAT_ID --text "THE_TEXT" - 更新发件箱状态为已发送,并记录message_id
跳过操作:
UPDATE outbox SET status = 'skipped', updated_at = strftime('%s','now') WHERE id = ?status — Queue statistics
status — 队列统计
sql
-- Inbox stats
SELECT status, count(*) FROM inbox GROUP BY status;
-- Outbox stats
SELECT status, count(*) FROM outbox GROUP BY status;
-- Recent activity
SELECT sender_name, route, status, datetime(created_at, 'unixepoch')
FROM inbox ORDER BY created_at DESC LIMIT 10;Report: pending count, drafts waiting, sent today, failed items.
sql
-- Inbox stats
SELECT status, count(*) FROM inbox GROUP BY status;
-- Outbox stats
SELECT status, count(*) FROM outbox GROUP BY status;
-- Recent activity
SELECT sender_name, route, status, datetime(created_at, 'unixepoch')
FROM inbox ORDER BY created_at DESC LIMIT 10;统计报告内容:待处理数量、待审核草稿数、今日已发送数、失败项数。
follow-ups — Track unanswered outbound messages
follow-ups — 追踪未回复的外发消息
Scan for people who haven't replied, send reminders with exponential backoff.
bash
undefined扫描未回复用户,按照指数退避规则发送提醒。
bash
undefinedScan for new unanswered messages (needs Telethon session — stop daemon first)
Scan for new unanswered messages (needs Telethon session — stop daemon first)
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py scan
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py scan
Process due reminders (drafts to Telegram or outbox)
Process due reminders (drafts to Telegram or outbox)
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py remind
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py remind
List active follow-ups
List active follow-ups
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py list
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py list
Archive expired follow-ups
Archive expired follow-ups
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py archive
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py archive
Run all (scan + check replies + remind + archive)
Run all (scan + check replies + remind + archive)
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py all
Also query directly:
```sql
SELECT sender_name, outbound_text, reminder_count, max_reminders,
datetime(outbound_at, 'unixepoch') as sent,
datetime(next_reminder_at, 'unixepoch') as next_ping,
status
FROM follow_ups
WHERE status = 'active'
ORDER BY next_reminder_at;Schedule: exponential (3d → 6d → 12d), fixed (every Nd), or custom per contact.
After max_reminders → archived. If they reply → auto-resolved.
python3 ~/.claude/skills/tg-responder/scripts/follow_ups.py all
也可直接查询数据库:
```sql
SELECT sender_name, outbound_text, reminder_count, max_reminders,
datetime(outbound_at, 'unixepoch') as sent,
datetime(next_reminder_at, 'unixepoch') as next_ping,
status
FROM follow_ups
WHERE status = 'active'
ORDER BY next_reminder_at;提醒计划:指数退避(3天→6天→12天)、固定间隔(每N天)或按联系人自定义。
达到最大提醒次数后自动归档;若用户回复则自动标记为已解决。
Database
数据库
Located at .
~/Brains/data/telegram/responder.db数据库路径:。
~/Brains/data/telegram/responder.dbConfig
配置文件
Located at . Edit contacts, modes, and ignore lists there.
~/.claude/skills/tg-responder/config.yaml配置文件路径:。可在此编辑联系人、模式和忽略列表。
~/.claude/skills/tg-responder/config.yamlWorker
工作进程
Start:
One-shot:
python3 ~/.claude/skills/tg-responder/scripts/worker.pypython3 ~/.claude/skills/tg-responder/scripts/worker.py --once启动命令:
单次执行:
python3 ~/.claude/skills/tg-responder/scripts/worker.pypython3 ~/.claude/skills/tg-responder/scripts/worker.py --once