mirror of
https://github.com/jackwener/wx-cli.git
synced 2026-10-08 16:05:45 +00:00
feat(biz): add wx biz-articles command to query public account messages (#33)
* feat(biz): add biz-articles command to query public account messages
加载 biz_message_0.db 提取公众号推送(标题/url/作者/时间)。
- daemon 端通过 DbCache 按需解密 biz_message_0.db(密钥已在 all_keys.json 中)
- 新增 IPC 变体 BizArticles(limit/account/since/until 参数)
- 新增 query 处理器 q_biz_articles:
- 通过 Name2Id 反查 gh_* username → md5 → Msg_<hash> 表映射
- 过滤 local_type & 0xFFFFFFFF = 49(appmsg 公众号文章)
- zstd 解压 + extract_cdata 解析 <mmreader>/<item> XML
- 支持多文章推送(一条消息含多篇文章)
- 输出字段:time/timestamp/recv_time/account/account_username/title/url/digest/cover_url
- 新增 CLI 子命令 wx biz-articles,参数:-n / --account / --since / --until / --json
- 新增工具函数 extract_cdata(CDATA 块解析)和 parse_biz_xml_items
- 新增 8 个单测(biz_tests 模块)覆盖 CDATA 解析和多文章场景
支持工作流:
wx biz-articles --since today --json | jq ".[].url" | xargs opencli weixin download
Verified: 返朴 ADHD 文章、Datawhale Claude Code 文章、土猛员外知识引擎文章均已正确提取。
* feat(biz-articles): add --unread filter (one latest article per account)
只列「有未读的公众号」的最近 1 篇文章 — 与 'wx unread --filter official'
行为一致,便于扫描"哪些公众号还有未读,标题是啥"。
- ipc.rs: BizArticles 加 unread: bool 字段(serde default = false 向后兼容)
- cli/mod.rs: --unread flag
- cli/biz_articles.rs: 透传 unread
- daemon/server.rs: dispatch 加 unread 参数
- daemon/query.rs: q_biz_articles
- 开启 --unread 时先查 session.db 拿 unread_count>0 且
chat_type==official_account 的 username 集合
- 与 --account 取交集(两者都给时进一步缩小范围)
- 空交集提前 return,避免无意义全表扫
- 解析后按 pub_time DESC 排,每个 account_username 只保留首条
- 最后再 truncate(limit)
* docs: PR draft - update --unread + --until usage
* chore(biz-articles): drop PR draft, document command, fix typo
- 删除 PR_DRAFT.md(误入 repo 的 PR 描述草稿,不该进 main)
- README.md / SKILL.md 补 biz-articles 用法
- query.rs: 密鑰 → 密钥
Co-authored-by: wx-cli-coder <coder@example.com>
---------
Co-authored-by: jackwener <jakevingoo@gmail.com>
Co-authored-by: wx-cli-coder <coder@example.com>
This commit is contained in:
co-authored by
wx-cli-coder
jackwener
parent
c284b4ade6
commit
dab3217d3f
@@ -196,6 +196,21 @@ wx sns-search "婚礼" --user "李四" --since 2023-01-01
|
||||
|
||||
朋友圈数据只覆盖你本地刷到过的帖子(微信 app 按需下载)。
|
||||
|
||||
### 公众号文章
|
||||
|
||||
公众号文章推送存在独立的 `biz_message_0.db`,用 `biz-articles` 单独查:
|
||||
|
||||
```bash
|
||||
wx biz-articles # 最近 50 篇
|
||||
wx biz-articles -n 200 # 更多
|
||||
wx biz-articles --account "返朴" # 限定公众号(名称模糊匹配)
|
||||
wx biz-articles --since 2026-05-01 --until 2026-05-10
|
||||
wx biz-articles --unread # 仅有未读的公众号,每号取最新 1 篇
|
||||
wx biz-articles --json | jq '.[].url' # 下游消费 URL
|
||||
```
|
||||
|
||||
每条返回:`account` / `account_username` / `title` / `url` / `digest` / `cover_url` / `time` / `timestamp` / `recv_time_str`。多图文推送会展开成多行。
|
||||
|
||||
### 联系人 & 群组
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user