Files
AgentsMeeting/src/ops/watch_group.py
T
hmo 1b2b935832 Initial: multi-agent XMPP communication system with dashboard
- Platform-based architecture (Windows/Linux/Mac)
- Agent instance registry (agents.yaml)
- Management dashboard with cross-platform monitoring
- xmpp_bot with HTTP bridge + health endpoints
- wechat_agent with WeChat-Hermes bridging
- Platform services: ProcessGuardian, HealthProbe, APIRouter, ChannelBridge
- Deployment: systemd (Linux) + PowerShell (Windows)
- Monitoring: SSH+ejabberdctl for cross-platform presence
2026-06-12 21:51:36 +08:00

37 lines
1.0 KiB
Python

"""
Monitor XMPP group messages from the HTTP bridge.
Prints new messages as they arrive. Press Ctrl+C to stop.
Usage: python watch_group.py [--from mohe]
"""
import sys, time, json, urllib.request
URL = "http://127.0.0.1:5802/messages"
SENDER = None
args = sys.argv[1:]
for i, a in enumerate(args):
if a == "--from" and i + 1 < len(args):
SENDER = args[i + 1]
last_ts = ""
while True:
try:
url = URL
if SENDER:
url += f"?from={SENDER}"
resp = urllib.request.urlopen(url, timeout=5)
data = json.loads(resp.read())
msgs = data.get("messages", [])
new_msgs = [m for m in msgs if m["ts"] > last_ts]
for m in new_msgs:
last_ts = m["ts"]
sender_tag = f"[{m['from']}]"
print(f"\n{sender_tag} {m['body']}")
print("---")
if new_msgs:
print(f"\n({len(new_msgs)} new, waiting...)", flush=True)
except Exception as e:
print(f"(poll error: {e})", flush=True)
time.sleep(3)