0ce5fa990b5e1ce5ca75213fc6d4e5ab9c375db8
- POST /hook with X-Gitea-Signature HMAC-SHA256 verification - X-Gitea-Delivery dedupe via sqlite deliveries table - threaded HTTP server + single dispatch worker draining a queue - polling (60s) kept as fallback; both paths enqueue to the same worker - gitea system webhook URL: http://10.42.0.1:31390/hook (cni0 gateway)
gitea-bot
麻薯(mochi)的全站 issue/PR 自动处理 bot——轮询 famzheng.me/gitea 所有 repo
的 open issue 和 PR,遇到"最新一条活动不是 mochi 自己"就 spawn
claude --dangerously-skip-permissions -p <prompt>,让 claude 自己用 mochi
token 调 gitea API + git push 完成回复 / 提 PR。
部署
跑在 famzheng.me 节点本机,systemd --user unit。
make install # 装到 ~/.config/systemd/user/,enable + start
make logs # tail -f 日志
make restart # 改完 bot.py 重启
make uninstall
依赖:
~/.gitea-mochi-token(mode 600,scopes=all)/home/fam/.local/bin/claude- python3 (stdlib only)
行为
bot.py 主循环每 60s:
GET /api/v1/repos/search拉所有 repo(mochi 是 admin 全部可见)- 对每个 repo,list open issues + open PRs
- 看每条最新活动的作者:是
mochi就跳过;其他人就 dispatch - dispatch = 把 repo / issue / 最近 10 条 comment 拼进 prompt,spawn claude
- claude 自己分类 → 留 comment / 提 PR / review;同语言回复,带 footer 签名
state 在 ~/.local/state/gitea-bot/state.db(sqlite,(repo#num) → last_signal_time)。
日志在 ~/.local/state/gitea-bot/bot.log(systemd append)。
文件
bot.py— 主循环gitea-bot.service— systemd --user unit(PATH 含~/.local/bin、~/.cargo/bin)Makefile— install / restart / logs
Description
Languages
Python
94.3%
Makefile
5.7%