返回顶部
u

unanswered-messages

Track and find unanswered messages using a local file-based inbox. No DB required. Use when asked to find unanswered messages, missed messages, people waiting for a response, or to log a new incoming message.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
54
下载量
0
收藏
概述
安装方式
版本历史

unanswered-messages

# Unanswered Messages (File-Based) Tracks messages sent to Heleni that haven't been replied to yet. **No DB required** — uses `/opt/ocana/openclaw/workspace/inbox/pending.json`. --- ## File Structure `/opt/ocana/openclaw/workspace/inbox/pending.json`: ```json { "version": 1, "messages": [ { "id": "MSG_ID", "ts": "2026-04-01T14:30:00Z", "chat_id": "+972XXXXXXXXX", "chat_name": "Netanel", "chat_type": "direct", "sender_name": "Netanel", "sender_phone": "+972XXXXXXXXX", "body": "message text...", "answered": false, "answered_at": null } ] } ``` --- ## 1. Log an Incoming Message When a message arrives that needs a response, add it to the file: ```python import json, datetime INBOX = "/opt/ocana/openclaw/workspace/inbox/pending.json" with open(INBOX) as f: data = json.load(f) data["messages"].append({ "id": "<message_id>", "ts": datetime.datetime.utcnow().isoformat() + "Z", "chat_id": "<chat_id>", "chat_name": "<chat_name>", "chat_type": "direct", # or "group" "sender_name": "<sender_name>", "sender_phone": "<sender_phone>", "body": "<message body, max 300 chars>", "answered": False, "answered_at": None }) with open(INBOX, "w") as f: json.dump(data, f, indent=2) ``` --- ## 2. Mark a Message as Answered After replying, mark it done: ```python import json, datetime INBOX = "/opt/ocana/openclaw/workspace/inbox/pending.json" with open(INBOX) as f: data = json.load(f) for msg in data["messages"]: if msg["id"] == "<message_id>": msg["answered"] = True msg["answered_at"] = datetime.datetime.utcnow().isoformat() + "Z" with open(INBOX, "w") as f: json.dump(data, f, indent=2) ``` --- ## 3. Find Unanswered Messages ```python import json from datetime import datetime, timedelta, timezone INBOX = "/opt/ocana/openclaw/workspace/inbox/pending.json" MAX_AGE_HOURS = 24 # ignore very old messages with open(INBOX) as f: data = json.load(f) cutoff = datetime.now(timezone.utc) - timedelta(hours=MAX_AGE_HOURS) unanswered = [ m for m in data["messages"] if not m["answered"] and datetime.fromisoformat(m["ts"].replace("Z", "+00:00")) > cutoff ] for m in sorted(unanswered, key=lambda x: x["ts"]): ts = datetime.fromisoformat(m["ts"].replace("Z", "+00:00")).strftime("%d/%m %H:%M") print(f"📩 {m['sender_name']} | {m['chat_name']} | {ts}") print(f" > {m['body'][:100]}") print(f" Message ID: {m['id']}") ``` --- ## 4. Cleanup — Remove Old Answered Messages Run periodically (e.g. weekly via heartbeat) to keep the file small: ```python import json from datetime import datetime, timedelta, timezone INBOX = "/opt/ocana/openclaw/workspace/inbox/pending.json" with open(INBOX) as f: data = json.load(f) cutoff = datetime.now(timezone.utc) - timedelta(days=7) data["messages"] = [ m for m in data["messages"] if not m["answered"] or datetime.fromisoformat(m["ts"].replace("Z", "+00:00")) > cutoff ] with open(INBOX, "w") as f: json.dump(data, f, indent=2) print(f"Kept {len(data['messages'])} messages") ``` --- ## Heartbeat Integration During heartbeat, check for unanswered messages from the last 2 hours: ```python import json from datetime import datetime, timedelta, timezone INBOX = "/opt/ocana/openclaw/workspace/inbox/pending.json" with open(INBOX) as f: data = json.load(f) cutoff = datetime.now(timezone.utc) - timedelta(hours=2) unanswered = [ m for m in data["messages"] if not m["answered"] and datetime.fromisoformat(m["ts"].replace("Z", "+00:00")) > cutoff ] if unanswered: # Alert Netanel or handle inline for m in unanswered: print(f"⚠️ לא ענינו ל-{m['sender_name']}: {m['body'][:80]}") ``` Add this check to `HEARTBEAT.md` under "Heartbeat Checks". --- ## Output Format Report unanswered messages as: - 📩 **[sender_name]** | [chat_name] | [DD/MM HH:MM] > [body preview, max 100 chars] > Message ID: [message_id] Group by chat if multiple from same conversation. --- ## Notes - ❌ No DB, no tunnel, no psql — pure file I/O - ✅ Works offline, works on AWS without Mac tunnel - Inbox file: `/opt/ocana/openclaw/workspace/inbox/pending.json` - Currently: messages are logged manually when Heleni decides to track them - Future: hook into inbound message handler to auto-log

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 unanswered-messages-1775884741 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 unanswered-messages-1775884741 技能

通过命令行安装

skillhub install unanswered-messages-1775884741

下载 Zip 包

⬇ 下载 unanswered-messages v1.0.0

文件大小: 2.26 KB | 发布时间: 2026-4-12 11:47

v1.0.0 最新 2026-4-12 11:47
Initial release — track unanswered messages via a local JSON file, no database needed.

- Add, find, and mark messages as answered using a simple file structure.
- Purge old answered messages periodically to keep the file small.
- Provides code snippets for logging, querying, and maintaining an unanswered messages inbox.
- Supports heartbeat integration to alert on recent unanswered messages.
- Designed for offline and AWS use with no external dependencies.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部