Webhooker
Webhooker 是基于 Kovi 框架的 Webhook 转发插件
通过配置 Webhook 端点和 json 访问路径,用户可以将发送到 Webhook 的 json payload 的指定字段交由 bot 转发
安装
- 根据教程创建一个 Kovi 工程
- 在项目根目录运行
- 在
build_bot!宏中传入插件
let bot = build_bot!;
配置
Webhooker 可以通过 toml 文件进行配置。如果配置文件不存在,则使用默认配置。
# 监听地址
= "0.0.0.0"
= 11451
= "Some Cool Auth Token" # 可选, 添加后需要通过 Bearer Auth 头鉴权
[[]]
= "/test" # 在 /webhook/test 添加 webhook 端点
= "Today's temperature is {temp}" # 字符串,具体规则见下方 values
= [
# 此处 `temp` 字段会从发过来的 POST json 中, 通过路径 `weather.temperature` 抽取数值
# 随后, `temp` 会填充到上方 message 的 {temp} 处
{ name = "temp", dotpath = "weather.temperature" },
]
= [123456789] # 要发送的群聊
= [987654321] # 要发送的用户
配置文件应放置于编译后与可执行文件同级的 data/kovi-plugin-webhooker/config.toml 中。