# gitea-bot 麻薯(mochi)的全站 issue/PR 自动处理 bot——轮询 `famzheng.me/gitea` 所有 repo 的 open issue 和 PR,遇到"最新一条活动不是 mochi 自己"就 spawn `claude --dangerously-skip-permissions -p `,让 claude 自己用 mochi token 调 gitea API + git push 完成回复 / 提 PR。 ## 部署 跑在 famzheng.me 节点本机,systemd `--user` unit。 ```sh 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: 1. `GET /api/v1/repos/search` 拉所有 repo(mochi 是 admin 全部可见) 2. 对每个 repo,list open issues + open PRs 3. 看每条最新活动的作者:是 `mochi` 就跳过;其他人就 dispatch 4. dispatch = 把 repo / issue / 最近 10 条 comment 拼进 prompt,spawn claude 5. 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