fix: 文档补充核心操作手册 — XMPP 发送的正确方式 (UTF-8 编码)

This commit is contained in:
hmo
2026-06-13 22:54:08 +08:00
parent 399c77ccbc
commit 0b99d6b07e
+42
View File
@@ -2,6 +2,48 @@
> 创建时间: 2026-06-12 04:00 > 创建时间: 2026-06-12 04:00
> 源会话: hermes session (ses_1d95d15c4ffehQaZ6hrbIbak5k) > 源会话: hermes session (ses_1d95d15c4ffehQaZ6hrbIbak5k)
## 🔴 关键操作手册(必读)
### 如何发送消息到 coregroup(核心群聊)
> **任何时候要向 coregroup 发消息,不要从 246 操作。用本地 HTTP bridge。**
```powershell
# ✅ 正确方式(UTF-8 编码,中文不会乱码)
$json = '{"message":"你好大家,开发完成,请 git pull 测试"}'
$bytes = [System.Text.Encoding]::UTF8.GetBytes($json)
Invoke-WebRequest -Uri "http://127.0.0.1:5802/send" -Method POST -Body $bytes -ContentType "application/json; charset=utf-8" -UseBasicParsing
# ❌ 错误 — Invoke-WebRequest -Body "字符串" 会走系统 GBK 编码,中文变问号
# ❌ 错误 — 不要从 246 发
# ❌ 错误 — 不要用 send_xmpp_groupmsg.py(没有 join MUC 被丢弃)
```
**原理:**
- 我的 XMPP bot JID: `xxm@yoin.fun`(运行在这个 Windows 机器上)
- bot 启动时已自动 join MUC rooms(含 `coregroup@conference.yoin.fun`
- HTTP bridge`xmpp_bot.py` 内置)绑定 `127.0.0.1:5802`
- 只有这个方式发的消息会出现在 coregroup 里
### 如何查看是否有新消息
```powershell
# 查看 mohe 发给我的消息
curl "http://127.0.0.1:5802/messages?from=mohe"
# 查看全部消息
curl "http://127.0.0.1:5802/messages"
```
### 状态检查
```powershell
# 检查 bot 是否在运行
Get-Process -Name python* | Where-Object { $_.CommandLine -match "xmpp_bot" }
# 检查 HTTP bridge 是否在监听
netstat -ano | findstr :5802
## 已完成 ## 已完成
### 系统修复 ### 系统修复