WebHooker/docs/zh/guide/routes.md
RhenCloud 4b99f6d33d
feat(feishu): add Feishu inbound webhook, /gh commands and card actions
- add feishu_links D1 table and link store helpers
- implement X-Lark-Signature verification, url_verification, /gh login|logout|comment|merge|close and card.action.trigger Merge/Close
- render interactive cards with clickable title link, inline links and callback buttons (no whole-card card_link)
- bind Feishu account in OAuth callback
- document event subscription and required scopes
2026-08-27 00:07:05 +08:00

4 KiB
Raw Permalink Blame History

路由与目标

路由决定哪些事件被转发到哪个频道Discord 或 Telegram。它们存储在 D1d1_routes,首次加载时从旧版 KV config:routes 键同步),可通过 Web 控制台Admin APIconfig.example.yaml 管理。

没有默认路由——每条路由都必须定义自己的目标。未配置任何路由时不会转发任何事件。每个实例最多可保存 200 条路由

路由模式

{
  "id": "unique-route-id",
  "name": "Human-readable name",
  "enabled": true,
  "groupId": "my-group",
  "fallback": false,
  "stop": false,
  "discordRoleIds": ["111111111111111111"],
  "filters": [
    { "type": "event", "match": "push" },
    { "type": "repo", "match": "org/repo", "exclude": false }
  ],
  "targets": [
    {
      "platform": "discord",
      "channelId": "REQUIRED_CHANNEL_ID",
      "threadId": "OPTIONAL_THREAD_ID"
    }
  ]
}

targets 的每一项都是一个推送目标,因此一条路由可同时转发到多个频道(例如一个 Discord 频道一个 Telegram 群组)。target.platform 选择平台:discord(默认)、telegramfeishuDiscord 目标要求 target.channelId(可选 target.threadId 指定子区);Telegram飞书 目标要求 target.chatId(群组/超级群组 id-1001234567890),可选 target.topicId(话题的 message_thread_id,相当于 Discord 子区)。没有默认频道回退。

字段 类型 必需 说明
groupId string 路由所属分组的 id
fallback boolean true 时仅在没有其他非 fallback 路由匹配时才触发;其自身过滤器被忽略
stop boolean true 且该路由匹配时,不再评估后续路由
discordRoleIds string[] 路由触发时要提醒的 Discord 身份组 id仅对 Discord 目标生效
ast object 布尔过滤器树({all:[...]} / {any:[...]} / {not:{...}});存在时优先于 filters

Discord 身份组提醒

在路由上设置 discordRoleIds 可在其触发时提醒一个或多个 Discord 身份组(角色)。提醒(<@&roleId>)会加在路由所有 Discord 目标的消息内容前Telegram 目标忽略该字段。只有当机器人拥有 Mention Everyone 权限(或身份组标记为可提及)且能看到该身份组时,提醒才会触发通知。

{
  "id": "release-notify",
  "name": "Notify on Release",
  "enabled": true,
  "groupId": "default",
  "discordRoleIds": ["111111111111111111", "222222222222222222"],
  "filters": [{ "type": "event", "match": "release" }],
  "targets": [{ "platform": "discord", "channelId": "REQUIRED_CHANNEL_ID" }]
}

也可以在管理控制台的 Discord 身份组提醒 中填写身份组 id。

过滤器

每条路由携带 filters 数组全部匹配才触发——AND 逻辑)。当路由带 ast 字段(嵌套的 all/any/not 树)时,用它替代 filters 求值,从而表达任意的布尔组合。见过滤器类型参考与过滤器教程

自定义路由示例

[
  {
    "id": "backend-prs",
    "name": "Backend PRs",
    "enabled": true,
    "groupId": "backend-team",
    "filters": [
      { "type": "repo", "match": "myorg/backend" },
      { "type": "event", "match": "pull_request" },
      { "type": "actor", "match": "[bot]", "exclude": true }
    ],
    "targets": [
      {
        "platform": "telegram",
        "chatId": "-1001234567890",
        "topicId": "9876543210"
      }
    ]
  }
]