Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MoGoldenFish/astrbot_plugin_githubandgitee_webhook

 
 

Repository files navigation

AstrBot GitHub Webhook Plugin

AstrBot 插件,用于接收 GitHub 事件(push、issues、pull requests 等)并转发到聊天平台(QQ 群组、私聊等)。

功能特性

  • ✅ 接收 GitHub Webhook 事件
  • ✅ 支持 Push 事件(代码提交)
  • ✅ 支持 Issues 事件(问题追踪)
  • ✅ 支持 Pull Request 事件(代码合并)
  • ✅ 实时转发到指定的聊天平台群组/用户
  • ✅ 自定义端口号配置
  • ✅ 简洁的消息格式,包含关键信息
  • ✅ Webhook Secret 签名验证(防止恶意请求)
  • ✅ 请求速率限制(防止消息轰炸)
  • ✅ 全面的错误处理和日志记录
  • ✅ LLM 智能消息生成(支持自定义提示词)
  • 🔜 自定义消息模板
  • 🔜 Release 事件支持

快速开始

安装

cd AstrBot/data/plugins
git clone https://github.com/TatsukiMengChen/astrbot_plugin_github_webhook.git
cd astrbot_plugin_github_webhook
pip install -r requirements.txt

配置

在 AstrBot WebUI 中配置插件,或编辑配置文件:

data/config/astrbot_plugin_github_webhook_config.json

{
  "port": 8080,
  "target_umo": "platform_id:GroupMessage:群号",
  "webhook_secret": "your_github_webhook_secret",
  "rate_limit": 10,
  "enable_agent": true,
  "llm_provider_id": "",
  "agent_timeout": 60,
  "agent_system_prompt": ""
}

重启

sudo systemctl restart astrbot
# 或手动重启 AstrBot

查看日志确认插件已加载:

[INFO] GitHub Webhook server started on port 8080

配置 GitHub Webhook

  1. 进入 GitHub 仓库 → SettingsWebhooksAdd webhook
  2. Payload URL: http://你的服务器IP:8080/webhook
  3. Content type: application/json
  4. Secret (可选): 配置 Webhook 密钥用于签名验证
  5. Events: 选择需要触发的事件(建议勾选 Pushes, Issues, Pull requests)
  6. Active: ✅ 勾选
  7. 点击 "Add webhook"

文档

详细的配置、使用和部署文档请查看 docs/ 目录:

LLM Prompt 示例

templates/ 目录中提供了预置的系统提示词:

目录结构

astrbot_plugin_github_webhook/
├── src/                          # Python 源代码
│   ├── core/                 # 核心管理
│   ├── handlers/              # 事件处理
│   ├── formatters/             # 消息格式化
│   ├── utils/                 # 工具函数
│   └── services/              # 业务服务
├── main.py                     # 插件入口
├── metadata.yaml               # 插件元数据
├── _conf_schema.json           # 配置 Schema
├── docs/                      # 详细文档
├── templates/                 # Prompt 模板
├── tests/                     # 测试代码
├── LICENSE                    # MIT 许可证
└── README.md                  # 本文件

详见 项目结构文档

依赖

  • aiohttp ≥ 3.11.0 - 异步 HTTP 服务器

开发计划

  • Issues 事件支持
  • Pull Request 事件支持
  • Release 事件支持
  • Webhook Secret 签名验证
  • 请求速率限制
  • 自定义消息模板(Jinja2)
  • Agent 集成(智能消息生成)
  • 分支过滤(仅监听 main 分支)
  • 多目标支持(不同事件发到不同群组)

贡献

欢迎提交 Issue 和 Pull Request!详见 开发文档

许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件

作者

TatsukiMengChen

致谢

相关链接

About

for gitee

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 83.1%
  • Shell 16.9%