WebHooker/docs/zh/guide/commands.md
RhenCloud a5324fb0ea
fix(formatters): localize PR buttons, cap oversized content, dedupe status logic
- PR merge/close button labels now follow the group language (actions.merge/close)
  instead of hardcoded Chinese
- clamp content to Discord embed limits (title 256, description 4096, field value
  1024, 25 fields) in formatters plus a render-layer safety net; Telegram gets a
  tag-safe 4096-char cap (capHtml closes dangling tags)
- raise commit subject truncation from 72 to 200 chars (MAX_COMMIT_SUBJECT)
- extract workflowStatus/workflowRunStatus/statusColorKey helpers shared by
  check_run/check_suite/workflow_run/workflow_job
- dedupe deployment ref/sha fields via addDeploymentRefFields
- commit_comment without a commit id uses title_plain (no dangling ???????)
- tag pushes now report 'Tag created'; zh push title includes the {ref}
- sender profile link derives from the repo's forge origin instead of github.com
- group webhook log emoji injected via emojiPrefix, removed from locale files
- dispatchEvent accepts preloaded groups (single KV read per webhook)
- webhook 401 logs distinguish 'secret not configured' from 'invalid signature'
2026-08-14 07:41:19 +08:00

3.6 KiB
Raw Blame History

机器人命令

绑定你的 GitHub 账号后,即可在 Discord 和 Telegram 上以本人身份操作 GitHub——评论使用你自己的 OAuth token 发布,权限由 GitHub 强制校验。若 GitHub 拒绝操作(例如编辑他人的评论),机器人会明确告知。

绑定账号

使用任何命令前,需先绑定一次 GitHub 账号:

平台 命令 效果
Discord /gh login 返回一条仅你可见的 OAuth 链接,用于授权 GitHub 账号
Discord /gh logout 解除绑定
Telegram /gh login(引用一条消息) 返回 OAuth 链接
Telegram /gh logout(引用一条消息) 解除绑定

链接保存在服务端KV并在 D1 中映射到你的 Discord/Telegram 用户 ID。

Discord

Discord 命令为斜杠命令消息右键菜单命令,由定时任务同步(每 5 分钟按服务器即时注册并全局注册24h 去重,约 1 小时传播)。所有回复均为临时消息(仅你可见)。

评论 issue / PR

两种等效方式:

  • 右键通知(推荐):右键机器人发出的 issue / PR / 评论通知 → 应用GitHub: 添加评论 / 编辑评论 / 删除评论。目标自动从通知嵌入中提取,无需链接。

  • 带链接的斜杠命令

    /gh comment add  link:<issue 或 PR 链接>    例如 https://github.com/owner/repo/issues/123
    /gh comment edit link:<评论链接>             链接需包含 #issuecomment-<id>
    /gh comment del  link:<评论链接>             链接需包含 #issuecomment-<id>
    

    edit / del 需要在 GitHub 上复制具体评论链接(评论 ⋯ 菜单 → 复制链接)。add / edit 会打开模态框输入/调整评论内容edit 会预填)。

合并 / 关闭 PR

开放 PR 的通知附带 合并 / 关闭 按钮(文案跟随分组的消息语言):

  • 点击按钮即以你绑定的 GitHub 账号合并squash或关闭 PR权限由 GitHub 强制校验。
  • 成功后按钮会从通知中移除,结果以临时消息展示。

前置条件

项目 如何满足
公钥 设置 DISCORD_PUBLIC_KEY 并配置 Interactions Endpoint URL
邀请 scope 机器人以 applications.commands scope 邀请(见 Discord Bot 设置
OAuth 配置 GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRETBASE_URL
绑定账号 每位用户先执行 /gh login

Telegram

Telegram /gh 命令通过引用一条通知消息来使用:

  • /gh login — 绑定 GitHub 账号(返回 OAuth 链接)
  • /gh logout — 解除绑定
  • /gh comment <文本> — 引用 issue/PR 通知以本人身份评论
  • /gh merge / /gh close — 引用 PR 通知进行合并/关闭

目标 issue/PR 从你引用的消息(通知嵌入中的链接)解析。命令通过 Telegram webhookPOST /telegram/webhook,可用 TELEGRAM_WEBHOOK_SECRET 校验)送达。