Conversation
审阅者指南(在小型 PR 上折叠)审阅者指南实现对新的 “send_new_member” 群公告模式的支持,更新群成员信息拉取逻辑并增加日志记录,根据类型将特定群公告路由到不同的 Web API 端点,并将项目版本提升到 7.12.7。 使用 send_new_member 模式发送群公告的时序图sequenceDiagram
actor BotUser
participant SendGroupNotice
participant NTQQWebApi
participant QQWebServerNotice
participant QQWebServerInstruction
BotUser->>SendGroupNotice: sendGroupNotice(payload)
SendGroupNotice->>SendGroupNotice: validate payload
SendGroupNotice->>SendGroupNotice: type = payload.send_new_member ? 20 : 1
SendGroupNotice->>NTQQWebApi: publishGroupBulletin(groupCode, content, type, pinned, isShowEditCard, tipWindowType, confirmRequired, imgId, imgWidth, imgHeight)
alt type == 20
NTQQWebApi->>QQWebServerInstruction: POST /cgi-bin/announce/add_qun_instruction
else type == 1
NTQQWebApi->>QQWebServerNotice: POST /cgi-bin/announce/add_qun_notice
end
NTQQWebApi-->>SendGroupNotice: response
SendGroupNotice-->>BotUser: success
更新后的 GetGroupMemberInfo 拉取与日志记录时序图sequenceDiagram
participant GetGroupMemberInfo
participant NTQQUserApi as NTQQUserApi
participant Logger
GetGroupMemberInfo->>NTQQUserApi: getUserDetailInfoWithBizInfo(uid)
alt primary call succeeds
NTQQUserApi-->>GetGroupMemberInfo: info
GetGroupMemberInfo->>Logger: info(info.simpleInfo.baseInfo)
GetGroupMemberInfo->>GetGroupMemberInfo: map info to OB11GroupMember
else primary call throws
GetGroupMemberInfo->>NTQQUserApi: fetchUserDetailInfo(uid)
alt fallback call succeeds
NTQQUserApi-->>GetGroupMemberInfo: fetchInfo
GetGroupMemberInfo->>GetGroupMemberInfo: info = fetchInfo.detail.get(uid)
GetGroupMemberInfo->>Logger: info(fetchUserDetailInfo)
GetGroupMemberInfo->>Logger: info(info.simpleInfo.baseInfo)
GetGroupMemberInfo->>GetGroupMemberInfo: map info to OB11GroupMember
else fallback call throws
GetGroupMemberInfo->>GetGroupMemberInfo: return without updating
end
end
更新后的群公告动作与 NTQQWebApi 的类图classDiagram
class BaseAction {
}
class SendGroupNotice {
+_handle(payload Payload) Promise~null~
}
SendGroupNotice --|> BaseAction
class Payload {
+number group_id
+string content
+boolean pinned
+boolean confirm_required
+boolean is_show_edit_card
+boolean tip_window
+boolean send_new_member
+string image
}
class GetGroupNotice {
+_handle(payload GetGroupNoticePayload) Promise~Notice[]~
}
GetGroupNotice --|> BaseAction
class GetGroupNoticePayload {
+number group_id
}
class Notice {
+number group_id
+string sender_id
+NoticeSetting setting
}
class NoticeSetting {
+boolean is_show_edit_card
+boolean tip_window
+boolean confirm_required
+boolean pinned
+boolean send_new_member
}
class NTQQWebApi {
+publishGroupBulletin(groupCode string, content string, type number, pinned number, isShowEditCard number, tipWindowType number, confirmRequired number, imgId string, imgWidth string, imgHeight string) Promise~void~
}
class GetGroupMemberInfo {
+_handle(payload GetGroupMemberInfoPayload) Promise~OB11GroupMember~
}
GetGroupMemberInfo --|> BaseAction
class GetGroupMemberInfoPayload {
+number group_id
+number user_id
}
class OB11GroupMember {
}
SendGroupNotice ..> Payload
GetGroupNotice ..> GetGroupNoticePayload
GetGroupNotice ..> Notice
Notice ..> NoticeSetting
GetGroupMemberInfo ..> GetGroupMemberInfoPayload
GetGroupMemberInfo ..> OB11GroupMember
SendGroupNotice ..> NTQQWebApi
文件级变更
提示与命令与 Sourcery 交互
自定义你的体验访问你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideImplements support for a new "send_new_member" group notice mode, updates group member info fetching with logging, routes specific group notices to a different web API endpoint based on type, and bumps the project version to 7.12.7. Sequence diagram for sending group notices with send_new_member modesequenceDiagram
actor BotUser
participant SendGroupNotice
participant NTQQWebApi
participant QQWebServerNotice
participant QQWebServerInstruction
BotUser->>SendGroupNotice: sendGroupNotice(payload)
SendGroupNotice->>SendGroupNotice: validate payload
SendGroupNotice->>SendGroupNotice: type = payload.send_new_member ? 20 : 1
SendGroupNotice->>NTQQWebApi: publishGroupBulletin(groupCode, content, type, pinned, isShowEditCard, tipWindowType, confirmRequired, imgId, imgWidth, imgHeight)
alt type == 20
NTQQWebApi->>QQWebServerInstruction: POST /cgi-bin/announce/add_qun_instruction
else type == 1
NTQQWebApi->>QQWebServerNotice: POST /cgi-bin/announce/add_qun_notice
end
NTQQWebApi-->>SendGroupNotice: response
SendGroupNotice-->>BotUser: success
Sequence diagram for updated GetGroupMemberInfo fetching and loggingsequenceDiagram
participant GetGroupMemberInfo
participant NTQQUserApi as NTQQUserApi
participant Logger
GetGroupMemberInfo->>NTQQUserApi: getUserDetailInfoWithBizInfo(uid)
alt primary call succeeds
NTQQUserApi-->>GetGroupMemberInfo: info
GetGroupMemberInfo->>Logger: info(info.simpleInfo.baseInfo)
GetGroupMemberInfo->>GetGroupMemberInfo: map info to OB11GroupMember
else primary call throws
GetGroupMemberInfo->>NTQQUserApi: fetchUserDetailInfo(uid)
alt fallback call succeeds
NTQQUserApi-->>GetGroupMemberInfo: fetchInfo
GetGroupMemberInfo->>GetGroupMemberInfo: info = fetchInfo.detail.get(uid)
GetGroupMemberInfo->>Logger: info(fetchUserDetailInfo)
GetGroupMemberInfo->>Logger: info(info.simpleInfo.baseInfo)
GetGroupMemberInfo->>GetGroupMemberInfo: map info to OB11GroupMember
else fallback call throws
GetGroupMemberInfo->>GetGroupMemberInfo: return without updating
end
end
Class diagram for updated group notice actions and NTQQWebApiclassDiagram
class BaseAction {
}
class SendGroupNotice {
+_handle(payload Payload) Promise~null~
}
SendGroupNotice --|> BaseAction
class Payload {
+number group_id
+string content
+boolean pinned
+boolean confirm_required
+boolean is_show_edit_card
+boolean tip_window
+boolean send_new_member
+string image
}
class GetGroupNotice {
+_handle(payload GetGroupNoticePayload) Promise~Notice[]~
}
GetGroupNotice --|> BaseAction
class GetGroupNoticePayload {
+number group_id
}
class Notice {
+number group_id
+string sender_id
+NoticeSetting setting
}
class NoticeSetting {
+boolean is_show_edit_card
+boolean tip_window
+boolean confirm_required
+boolean pinned
+boolean send_new_member
}
class NTQQWebApi {
+publishGroupBulletin(groupCode string, content string, type number, pinned number, isShowEditCard number, tipWindowType number, confirmRequired number, imgId string, imgWidth string, imgHeight string) Promise~void~
}
class GetGroupMemberInfo {
+_handle(payload GetGroupMemberInfoPayload) Promise~OB11GroupMember~
}
GetGroupMemberInfo --|> BaseAction
class GetGroupMemberInfoPayload {
+number group_id
+number user_id
}
class OB11GroupMember {
}
SendGroupNotice ..> Payload
GetGroupNotice ..> GetGroupNoticePayload
GetGroupNotice ..> Notice
Notice ..> NoticeSetting
GetGroupMemberInfo ..> GetGroupMemberInfoPayload
GetGroupMemberInfo ..> OB11GroupMember
SendGroupNotice ..> NTQQWebApi
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体反馈:
- 在
GetGroupMemberInfo中,目前在使用fetchUserDetailInfo的返回结果前,没有再检查其是否为 null/undefined;建议在访问fetchInfo.detail.get(member.uid)之前恢复原有的保护判断(或进行类型断言),以避免潜在的运行时错误。 - 在
SendGroupNotice和NTQQWebApi.publishGroupBulletin中,将20作为send_new_member的特殊type使用,这是一个“魔法数字”;建议将其提取为具名常量或枚举,以使意图更清晰,并降低误用的风险。 - 在
GetGroupMemberInfo中新增的logger.info调用会在每次请求时打印日志,在生产环境中可能会过于嘈杂;建议使用更细粒度的日志级别(例如 debug),或者在单条日志中增加更多上下文信息,而不是多次调用。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `GetGroupMemberInfo`, the `fetchUserDetailInfo` result is now used without checking for null/undefined; consider restoring a guard (or asserting its type) before accessing `fetchInfo.detail.get(member.uid)` to avoid potential runtime errors.
- The use of `20` as the special `type` for `send_new_member` (in both `SendGroupNotice` and `NTQQWebApi.publishGroupBulletin`) is a magic number; consider extracting it into a named constant or enum to make the intent clearer and reduce the chance of misuse.
- The new `logger.info` calls in `GetGroupMemberInfo` log on every request and may be noisy in production; consider using a more granular log level (e.g., debug) or including more contextual information in a single log line instead of multiple calls.
## Individual Comments
### Comment 1
<location path="src/onebot11/action/group/GetGroupMemberInfo.ts" line_range="41" />
<code_context>
}
}
if (info) {
+ this.ctx.logger.info(info.simpleInfo.baseInfo)
ret.sex = OB11Entities.sex(info.simpleInfo.baseInfo.sex)
ret.qq_level = info.commonExt?.qqLevel && calcQQLevel(info.commonExt.qqLevel) || 0
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider lowering the log level or removing this log to avoid verbose/PII-heavy output.
This logs the full `info.simpleInfo.baseInfo` object at `info` level on every call, which can be large and may include sensitive user data. If this is primarily for debugging, please either lower the level (debug/trace) or log only a minimal identifier (e.g., UID) to reduce noise and privacy risk.
</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:
- In
GetGroupMemberInfo, thefetchUserDetailInforesult is now used without checking for null/undefined; consider restoring a guard (or asserting its type) before accessingfetchInfo.detail.get(member.uid)to avoid potential runtime errors. - The use of
20as the specialtypeforsend_new_member(in bothSendGroupNoticeandNTQQWebApi.publishGroupBulletin) is a magic number; consider extracting it into a named constant or enum to make the intent clearer and reduce the chance of misuse. - The new
logger.infocalls inGetGroupMemberInfolog on every request and may be noisy in production; consider using a more granular log level (e.g., debug) or including more contextual information in a single log line instead of multiple calls.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `GetGroupMemberInfo`, the `fetchUserDetailInfo` result is now used without checking for null/undefined; consider restoring a guard (or asserting its type) before accessing `fetchInfo.detail.get(member.uid)` to avoid potential runtime errors.
- The use of `20` as the special `type` for `send_new_member` (in both `SendGroupNotice` and `NTQQWebApi.publishGroupBulletin`) is a magic number; consider extracting it into a named constant or enum to make the intent clearer and reduce the chance of misuse.
- The new `logger.info` calls in `GetGroupMemberInfo` log on every request and may be noisy in production; consider using a more granular log level (e.g., debug) or including more contextual information in a single log line instead of multiple calls.
## Individual Comments
### Comment 1
<location path="src/onebot11/action/group/GetGroupMemberInfo.ts" line_range="41" />
<code_context>
}
}
if (info) {
+ this.ctx.logger.info(info.simpleInfo.baseInfo)
ret.sex = OB11Entities.sex(info.simpleInfo.baseInfo.sex)
ret.qq_level = info.commonExt?.qqLevel && calcQQLevel(info.commonExt.qqLevel) || 0
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider lowering the log level or removing this log to avoid verbose/PII-heavy output.
This logs the full `info.simpleInfo.baseInfo` object at `info` level on every call, which can be large and may include sensitive user data. If this is primarily for debugging, please either lower the level (debug/trace) or log only a minimal identifier (e.g., UID) to reduce noise and privacy risk.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
| } | ||
| if (info) { | ||
| this.ctx.logger.info(info.simpleInfo.baseInfo) |
There was a problem hiding this comment.
🚨 suggestion (security): 建议降低该日志的级别或移除这条日志,以避免产生过于冗长或包含大量个人敏感信息(PII)的输出。
当前在每次调用时,会以 info 级别记录完整的 info.simpleInfo.baseInfo 对象,该对象可能较大,并可能包含敏感的用户数据。如果这主要用于调试,请考虑将级别降低到 debug/trace,或者只记录最小化的标识信息(例如 UID),以减少噪声并降低隐私风险。
Original comment in English
🚨 suggestion (security): Consider lowering the log level or removing this log to avoid verbose/PII-heavy output.
This logs the full info.simpleInfo.baseInfo object at info level on every call, which can be large and may include sensitive user data. If this is primarily for debugging, please either lower the level (debug/trace) or log only a minimal identifier (e.g., UID) to reduce noise and privacy risk.
Test Report
✅ All tests passed |
由 Sourcery 提供的摘要
添加对以群公告变体形式发送和获取群组“新成员说明”的支持,增强成员信息获取的日志记录,并将项目版本升级到 7.12.7。
新功能:
send_new_member标记支持将群公告配置为以新成员说明的形式发送。send_new_member状态。增强:
构建:
文档:
杂项:
Original summary in English
Summary by Sourcery
Add support for sending and retrieving group instructions as a variant of group notices, enhance member info retrieval logging, and bump the project version to 7.12.7.
New Features:
Enhancements:
Build:
Documentation:
Chores: