Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 群名称变更事件 #664

Merged
merged 1 commit into from
Dec 28, 2024
Merged

Conversation

clansty
Copy link
Contributor

@clansty clansty commented Dec 28, 2024

自定义事件 notice.notify.group_name

gocq 和 onebot11 规范里面并没有找到这样的事件,所以作为 napcat 自定义事件添加

Summary by Sourcery

新功能:

  • 添加了 notice.notify.group_name 事件,当群组名称更改时触发。
Original summary in English

Summary by Sourcery

New Features:

  • Added notice.notify.group_name event, which is triggered when a group name is changed.

Copy link

sourcery-ai bot commented Dec 28, 2024

审核指南由 Sourcery 提供

此拉取请求实现了一个新的自定义事件,notice.notify.group_name,用于处理群组名称更改。它引入了一个新的 OB11GroupNameEvent 类,并在 OneBotGroupApi 类中添加了群组名称更改事件的解析逻辑。

群组名称更改事件处理的时序图

sequenceDiagram
    participant User as Group Admin
    participant Bot
    participant OneBotGroupApi
    participant OB11GroupNameEvent

    User->>Bot: 更改群组名称
    Bot->>OneBotGroupApi: 接收原始消息
    OneBotGroupApi->>OneBotGroupApi: parseGrayTipElement()
    OneBotGroupApi->>OneBotGroupApi: parseGroupElement()
    Note over OneBotGroupApi: 检查类型是否为 KGROUPNAMEMODIFIED
    OneBotGroupApi->>OB11GroupNameEvent: 创建新事件
    Note over OB11GroupNameEvent: 存储新群组名称
Loading

群组名称事件实现的类图

classDiagram
    class OB11GroupNoticeEvent {
        +notice_type: string
    }
    class OB11GroupNameEvent {
        +notice_type: string
        +name_new: string
        +constructor(core: NapCatCore, groupId: number, userId: number, nameNew: string)
    }
    class OneBotGroupApi {
        +parseGroupElement(msg: RawMessage, element: TipGroupElement, elementWrapper: GrayTipElement)
        +parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement)
    }
    OB11GroupNoticeEvent <|-- OB11GroupNameEvent
    note for OB11GroupNameEvent "用于处理群组名称更改的新类"
Loading

文件级更改

更改 详情 文件
添加 OB11GroupNameEvent 类以表示群组名称更改事件。
  • 创建了 OB11GroupNameEvent 类,继承自 OB11GroupNoticeEvent
  • OB11GroupNameEvent 类中添加了属性 notice_typename_new
  • 实现了 OB11GroupNameEvent 类的构造函数,以初始化事件属性,包括群组 ID、用户 ID 和新群组名称。
src/onebot/event/notice/OB11GroupNameEvent.ts
OneBotGroupApi 中实现了群组名称更改事件的解析逻辑。
  • 添加了 parseGroupElement 方法以处理群组名称更改事件。
  • parseGroupElement 中添加了检查 TipGroupElementType.KGROUPNAMEMODIFIED 事件的逻辑。
  • 在接收到群组名称更改事件时创建一个新的 OB11GroupNameEvent 实例。
  • parseGroupElement 方法集成到 parseGrayTipElement 方法中,以处理来自灰色提示消息的群组名称更改事件。
src/onebot/api/group.ts

提示和命令

与 Sourcery 互动

  • 触发新审核: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub 问题: 通过回复审核评论请求 Sourcery 从中创建一个问题。
  • 生成拉取请求标题: 在拉取请求标题的任何地方写 @sourcery-ai 以随时生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何地方写 @sourcery-ai summary 以随时生成 PR 摘要。您也可以使用此命令指定摘要应插入的位置。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审核功能,如 Sourcery 生成的拉取请求摘要、审核指南等。
  • 更改审核语言。
  • 添加、删除或编辑自定义审核说明。
  • 调整其他审核设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request implements a new custom event, notice.notify.group_name, to handle group name changes. It introduces a new OB11GroupNameEvent class and adds parsing logic for group name change events in the OneBotGroupApi class.

Sequence diagram for group name change event handling

sequenceDiagram
    participant User as Group Admin
    participant Bot
    participant OneBotGroupApi
    participant OB11GroupNameEvent

    User->>Bot: Changes group name
    Bot->>OneBotGroupApi: Receives raw message
    OneBotGroupApi->>OneBotGroupApi: parseGrayTipElement()
    OneBotGroupApi->>OneBotGroupApi: parseGroupElement()
    Note over OneBotGroupApi: Checks if type is KGROUPNAMEMODIFIED
    OneBotGroupApi->>OB11GroupNameEvent: Creates new event
    Note over OB11GroupNameEvent: Stores new group name
Loading

Class diagram for group name event implementation

classDiagram
    class OB11GroupNoticeEvent {
        +notice_type: string
    }
    class OB11GroupNameEvent {
        +notice_type: string
        +name_new: string
        +constructor(core: NapCatCore, groupId: number, userId: number, nameNew: string)
    }
    class OneBotGroupApi {
        +parseGroupElement(msg: RawMessage, element: TipGroupElement, elementWrapper: GrayTipElement)
        +parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement)
    }
    OB11GroupNoticeEvent <|-- OB11GroupNameEvent
    note for OB11GroupNameEvent "New class for handling group name changes"
Loading

File-Level Changes

Change Details Files
Added OB11GroupNameEvent class to represent group name change events.
  • Created the OB11GroupNameEvent class, which extends OB11GroupNoticeEvent.
  • Added properties notice_type and name_new to the OB11GroupNameEvent class.
  • Implemented the constructor for the OB11GroupNameEvent class to initialize the event properties including group ID, user ID, and new group name
src/onebot/event/notice/OB11GroupNameEvent.ts
Implemented parsing logic for group name change events in OneBotGroupApi.
  • Added the parseGroupElement method to handle group name change events.
  • Added logic within parseGroupElement to check for TipGroupElementType.KGROUPNAMEMODIFIED events.
  • Created a new OB11GroupNameEvent instance upon receiving a group name change event.
  • Integrated the parseGroupElement method into the parseGrayTipElement method to process group name change events from gray tip messages.
src/onebot/api/group.ts

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@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.

@clansty - 我已经审查了你的更改 - 这里有一些反馈:

总体评论

  • 考虑添加文档来描述这个自定义事件类型,包括其结构和触发条件,因为它不是标准协议的一部分。
这是我在审查期间查看的内容
  • 🟢 一般问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @clansty - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding documentation to describe this custom event type, including its structure and trigger conditions, since it's not part of the standard protocol.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@MliKiowa MliKiowa merged commit f1d83f7 into NapNeko:main Dec 28, 2024
4 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.

2 participants