Skip to content

chore: update version to 7.12.12#759

Merged
idranme merged 3 commits into
mainfrom
dev
May 4, 2026
Merged

chore: update version to 7.12.12#759
idranme merged 3 commits into
mainfrom
dev

Conversation

@idranme
Copy link
Copy Markdown
Collaborator

@idranme idranme commented May 4, 2026

Summary by Sourcery

处理更多富媒体消息类型,并调整 WebSocket 心跳行为。

增强内容:

  • 扩展富媒体解码能力,根据业务类型和服务类型元数据,同时支持图片和视频消息。
  • 无论事件过滤器如何配置,始终发送 WebSocket 心跳事件。
Original summary in English

Summary by Sourcery

Handle additional rich media message types and adjust WebSocket heartbeat behavior.

Enhancements:

  • Extend rich media decoding to support both image and video messages based on business type and service type metadata.
  • Always send WebSocket heartbeat events regardless of event filter configuration.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 4, 2026

审查者指南(Reviewer's Guide)

扩展多消息解码能力,通过 businessType 区分图片和视频富媒体,同时简化 WebSocket 心跳逻辑:始终发送心跳事件,并对文档路径做了一个小的调整。

无过滤条件时 WebSocket 心跳事件发送的时序图

sequenceDiagram
  participant OB11WebSocket
  participant Context
  participant Client

  OB11WebSocket->>Context: interval(callback, heartInterval)
  Context-->>OB11WebSocket: schedule periodic callback

  loop every heartInterval
    OB11WebSocket->>OB11WebSocket: create OB11HeartbeatEvent(online, true, heartInterval)
    OB11WebSocket->>Client: reply(socket, OB11HeartbeatEvent)
  end

  participant OB11WebSocketReverse
  participant ReverseContext as Context_reverse
  participant WsClient

  OB11WebSocketReverse->>ReverseContext: interval(callback, heartInterval)
  ReverseContext-->>OB11WebSocketReverse: schedule periodic callback

  loop every heartInterval when WsClient exists
    OB11WebSocketReverse->>OB11WebSocketReverse: create OB11HeartbeatEvent(online, true, heartInterval)
    OB11WebSocketReverse->>WsClient: reply(wsClient, OB11HeartbeatEvent)
  end
Loading

文件级变更

变更 详情 文件
扩展富媒体多消息解码,基于 commonElembusinessTypeserviceType 同时支持图片和视频分段。
  • 将原来针对特定 serviceType 的条件扩大为对任意 commonElem 的检查,并解构出 businessTypeserviceTypepbElem 以便复用。
  • businessType 为 10/20 且 serviceType 为 48 的情况,保留并包裹现有的富媒体图片解码逻辑到一个新的分支中。
  • 新增一个分支处理 businessType 为 11/21 且 serviceType 为 48 的情况:解码视频信息,通过 ntFileApi.getVideoUrlByPacket 解析视频 URL,并发出带文件元数据的 OB11MessageDataType.Video 分段。
src/onebot11/helper/decodeMultiMessage.ts
在 WebSocket 连接上始终发送心跳事件,不再应用事件过滤器。
  • 在标准 WebSocket 服务器实现中,移除发送 OB11HeartbeatEvent 前的 matchEventFilter 检查。
  • 在反向 WebSocket 客户端实现中,移除发送 OB11HeartbeatEvent 前的 matchEventFilter 检查。
src/onebot11/connect/ws.ts
调整仓库结构中的文档文件路径。
  • 将一个文本文档从 a/doc 目录重命名或移动到 b/doc 目录,并使用编码后的文件名。
"a/doc/\346\233\264\346\226\260\346\227\245\345\277\227.txt"
"b/doc/\346\233\264\346\226\260\346\227\245\345\277\227.txt"

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 在某条审查评论下回复,要求 Sourcery 基于该评论创建 issue。你也可以回复 @sourcery-ai issue 来从该评论创建一个 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文中任意位置写上 @sourcery-ai summary,即可在相应位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,将所有 Sourcery 评论标记为已解决。适用于你已经处理完所有评论且不希望继续看到它们的情况。
  • 撤销所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,以撤销所有现有的 Sourcery 审查。尤其适用于希望从头开始一次新审查的情况——别忘了再次评论 @sourcery-ai review 以触发新的审查!

自定义你的体验

访问你的 控制面板 以:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 Pull Request 摘要、审查者指南等。
  • 修改审查语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Expands multi-message decoding to distinguish image and video rich media by businessType while simplifying WebSocket heartbeat behavior by always emitting heartbeat events, plus a minor doc path adjustment.

Sequence diagram for WebSocket heartbeat emission without filtering

sequenceDiagram
  participant OB11WebSocket
  participant Context
  participant Client

  OB11WebSocket->>Context: interval(callback, heartInterval)
  Context-->>OB11WebSocket: schedule periodic callback

  loop every heartInterval
    OB11WebSocket->>OB11WebSocket: create OB11HeartbeatEvent(online, true, heartInterval)
    OB11WebSocket->>Client: reply(socket, OB11HeartbeatEvent)
  end

  participant OB11WebSocketReverse
  participant ReverseContext as Context_reverse
  participant WsClient

  OB11WebSocketReverse->>ReverseContext: interval(callback, heartInterval)
  ReverseContext-->>OB11WebSocketReverse: schedule periodic callback

  loop every heartInterval when WsClient exists
    OB11WebSocketReverse->>OB11WebSocketReverse: create OB11HeartbeatEvent(online, true, heartInterval)
    OB11WebSocketReverse->>WsClient: reply(wsClient, OB11HeartbeatEvent)
  end
Loading

File-Level Changes

Change Details Files
Expand rich media multi-message decoding to support both image and video segments based on commonElem businessType and serviceType.
  • Broaden conditional from a specific serviceType check to any commonElem, destructuring businessType, serviceType, and pbElem for reuse.
  • For businessType 10/20 with serviceType 48, retain and wrap existing rich media image decoding logic inside a new conditional branch.
  • Add a new branch for businessType 11/21 with serviceType 48 to decode video info, resolve a video URL via ntFileApi.getVideoUrlByPacket, and emit an OB11MessageDataType.Video segment with file metadata.
src/onebot11/helper/decodeMultiMessage.ts
Always send heartbeat events on WebSocket connections without applying the event filter.
  • Remove matchEventFilter checks before sending OB11HeartbeatEvent in the standard WebSocket server implementation.
  • Remove matchEventFilter checks before sending OB11HeartbeatEvent in the reverse WebSocket client implementation.
src/onebot11/connect/ws.ts
Adjust documentation file path within the repository layout.
  • Rename or move a documentation text file from the 'a/doc' directory to 'b/doc' with an encoded filename.
"a/doc/\346\233\264\346\226\260\346\227\245\345\277\227.txt"
"b/doc/\346\233\264\346\226\260\346\227\245\345\277\227.txt"

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:

  • businessType 检查 (businessType === 10 || businessType === 20)(businessType === 11 || businessType === 21) 引入了若干“魔法数字”;建议将这些值提取为有含义的常量或枚举,以便让意图更清晰,并降低未来出错的风险。
  • serviceType === 48 分支中,你现在会解码 Media.MsgInfo 并在图片和视频路径中都访问 msgInfoBody[0] 及其 index;建议将这部分逻辑抽取成一个小的辅助函数,以避免重复并让富媒体解码流程更易于维护。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `businessType` checks `(businessType === 10 || businessType === 20)` and `(businessType === 11 || businessType === 21)` introduce several magic numbers; consider extracting these into named constants or an enum to make the intent clearer and reduce the chance of future mistakes.
- In the `serviceType === 48` branch you now decode `Media.MsgInfo` and access `msgInfoBody[0]` and its `index` in both image and video paths; consider factoring this into a small helper to avoid duplication and make the rich media decoding flow easier to maintain.

## Individual Comments

### Comment 1
<location path="src/onebot11/helper/decodeMultiMessage.ts" line_range="40-31" />
<code_context>
+              file_size: info!.fileSize!.toString(),
+            }
+          }
+        } else if (serviceType === 48 && (businessType === 11 || businessType === 21)) {
+          const { msgInfoBody } = Media.MsgInfo.decode(pbElem)
+          const { index } = msgInfoBody[0]
+          const url = await ctx.ntFileApi.getVideoUrlByPacket(index.fileUuid, businessType === 21)
+          segment = {
+            type: OB11MessageDataType.Video,
+            data: {
+              file: index.info.fileName,
+              url,
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against missing or malformed `msgInfoBody[0].index` when decoding video messages.

This branch dereferences `msgInfoBody[0].index` (including `fileUuid` and `info` fields) without checks. If `msgInfoBody` is empty or `index`/`info` is absent (e.g., upstream proto/server issues), this will throw and can crash the decode pipeline. Please add a minimal guard (e.g., early-return when `msgInfoBody[0]?.index?.info` or `fileUuid` is missing) so malformed packets fail gracefully instead of causing runtime errors.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The businessType checks (businessType === 10 || businessType === 20) and (businessType === 11 || businessType === 21) introduce several magic numbers; consider extracting these into named constants or an enum to make the intent clearer and reduce the chance of future mistakes.
  • In the serviceType === 48 branch you now decode Media.MsgInfo and access msgInfoBody[0] and its index in both image and video paths; consider factoring this into a small helper to avoid duplication and make the rich media decoding flow easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `businessType` checks `(businessType === 10 || businessType === 20)` and `(businessType === 11 || businessType === 21)` introduce several magic numbers; consider extracting these into named constants or an enum to make the intent clearer and reduce the chance of future mistakes.
- In the `serviceType === 48` branch you now decode `Media.MsgInfo` and access `msgInfoBody[0]` and its `index` in both image and video paths; consider factoring this into a small helper to avoid duplication and make the rich media decoding flow easier to maintain.

## Individual Comments

### Comment 1
<location path="src/onebot11/helper/decodeMultiMessage.ts" line_range="40-31" />
<code_context>
+              file_size: info!.fileSize!.toString(),
+            }
+          }
+        } else if (serviceType === 48 && (businessType === 11 || businessType === 21)) {
+          const { msgInfoBody } = Media.MsgInfo.decode(pbElem)
+          const { index } = msgInfoBody[0]
+          const url = await ctx.ntFileApi.getVideoUrlByPacket(index.fileUuid, businessType === 21)
+          segment = {
+            type: OB11MessageDataType.Video,
+            data: {
+              file: index.info.fileName,
+              url,
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against missing or malformed `msgInfoBody[0].index` when decoding video messages.

This branch dereferences `msgInfoBody[0].index` (including `fileUuid` and `info` fields) without checks. If `msgInfoBody` is empty or `index`/`info` is absent (e.g., upstream proto/server issues), this will throw and can crash the decode pipeline. Please add a minimal guard (e.g., early-return when `msgInfoBody[0]?.index?.info` or `fileUuid` is missing) so malformed packets fail gracefully instead of causing runtime errors.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

const url = parsedUrl.href + (imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey)
const { info } = richMediaInfo.msgInfoBody[0].index!
const { pic } = richMediaInfo.extBizInfo!
segment = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 在解码视频消息时,需要防范 msgInfoBody[0].index 缺失或格式异常。

当前分支在没有任何检查的情况下直接解引用 msgInfoBody[0].index(包括其中的 fileUuidinfo 字段)。如果 msgInfoBody 为空,或者 index/info 缺失(例如上游 proto/服务端的问题),这里会抛异常并导致解码流水线崩溃。请添加一个最小化的防护(例如,当 msgInfoBody[0]?.index?.infofileUuid 缺失时直接提前返回),这样可以让格式异常的包以优雅失败的方式处理,而不是引发运行时错误。

Original comment in English

issue (bug_risk): Guard against missing or malformed msgInfoBody[0].index when decoding video messages.

This branch dereferences msgInfoBody[0].index (including fileUuid and info fields) without checks. If msgInfoBody is empty or index/info is absent (e.g., upstream proto/server issues), this will throw and can crash the decode pipeline. Please add a minimal guard (e.g., early-return when msgInfoBody[0]?.index?.info or fileUuid is missing) so malformed packets fail gracefully instead of causing runtime errors.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Test Report

Job Status
unit-test ✅ success
e2e-test ✅ success

✅ All tests passed

@idranme idranme merged commit 3ca5c60 into main May 4, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant