| name | xiaoheihe |
| description | 操作小黑盒(heybox)社区——刷首页推荐、按关键词搜帖、读帖子正文和评论区、发评论、发帖或存草稿、点赞、收藏、关注用户。当用户提到小黑盒、heybox、逛帖、发帖、盒友社区,或要求在小黑盒上查看/发布内容时使用。 |
小黑盒社区操作
所有操作都通过同目录下的 scripts/xhh.py 完成。它使用插件已保存的登录态,
每个子命令向 stdout 输出一个 JSON 对象,失败时 ok 为 false 且退出码为 1。
python <skill_dir>/scripts/xhh.py <子命令> [参数]
<skill_dir> 是本 SKILL.md 所在目录。先执行 whoami 确认登录态可用。
浏览
python scripts/xhh.py whoami
python scripts/xhh.py feed --limit 10
python scripts/xhh.py search "关键词" --limit 10
python scripts/xhh.py read <link_id>
python scripts/xhh.py topics
python scripts/xhh.py topics --search "游戏"
feed / search 返回的每条帖子都带 link_id,read 和后续写操作都用它定位;
read 返回的评论带 comment_id,给 support 用。不要自己拼 ID 或 URL。
追踪自己
python scripts/xhh.py notifications
python scripts/xhh.py notifications --type mention
python scripts/xhh.py mine posts
python scripts/xhh.py mine comments
python scripts/xhh.py mine favours
python scripts/xhh.py drafts
python scripts/xhh.py dm list
python scripts/xhh.py dm list --strangers
python scripts/xhh.py dm read <user_id>
dm read 每条带 from_me,区分是自己发的还是对方发的。
notifications 是回复别人的入口:每条带 user_name、text(对方说了什么)、
link_id 和 comment_id,直接拿去 comment <link_id> --reply-id <comment_id> 就能回。
发完帖之后想找回帖子用 mine posts,存过的草稿用 drafts。
发布与互动
这些操作会以当前登录账号在公开社区留下痕迹。
python scripts/xhh.py comment <link_id> --text "内容"
python scripts/xhh.py comment <link_id> --text-file /tmp/reply.txt
python scripts/xhh.py comment <link_id> --text "回复" --reply-id <comment_id>
python scripts/xhh.py post --title "标题" --text-file /tmp/body.html \
--topic-id 58144 --hashtag "标签" --image /path/a.png
python scripts/xhh.py post --title "标题" --text-file /tmp/body.html --draft
python scripts/xhh.py dm send <user_id> --text "内容"
python scripts/xhh.py dm send <user_id> --text-file /tmp/msg.txt --image /path/a.png
python scripts/xhh.py award <link_id>
python scripts/xhh.py favour <link_id>
python scripts/xhh.py support <comment_id>
python scripts/xhh.py follow <user_id>
删除
删帖和删草稿不可撤销,是唯一保留确认参数的操作:
python scripts/xhh.py delete <link_id> --confirm
python scripts/xhh.py delete <link_id> --draft --confirm
先用 mine posts 或 drafts 拿到准确的 link_id,把标题念给用户确认后再删。
正文用 --text-file
正文含换行、引号、HTML 标签时一律先写进临时文件再用 --text-file,不要塞进
--text 里跟 shell 转义搏斗。正文支持简单 HTML(<p> <br> <b> <a>)。
发帖注意
- 发帖前先跑
topics 拿到 topic_id,选一个内容对得上的分区;不确定就问用户
--image 接本地路径或 HTTP 图片 URL,脚本会自动转存到小黑盒 CDN 并补齐宽高
- 不确定排版效果时,先
--draft 存草稿让用户去 App 里看,确认后再正式发布
--post-type 2(长文章)额外需要 --thumb、--post-plan、--original,
一般用默认的图文帖即可
失败处理
没有可用的小黑盒登录态 → 让用户去插件 login 页扫码登录
帖子正文超过上限 → 内容太长,精简后重试
- 其他错误把
error 原文转述给用户,不要重试到成功为止
参考
发帖接口的完整字段说明见 references/post-api.md,只在需要调试发帖请求或
扩展脚本时才读它。