Skip to content

增加监听wechatpadpro消息平台的事件 #1998

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

diudiu62
Copy link
Contributor

@diudiu62 diudiu62 commented Jul 2, 2025

修正pilk依赖提示文案
增加监听wechatpadpro消息平台的事件

好的,这是翻译成中文的 pull request 总结:

Sourcery 总结

添加对监听 wechatpadpro 平台事件的支持并更正 pilk 依赖错误消息

新特性:

  • 将 WECHATPADPRO 添加到 PlatformAdapterType 并在适配器名称映射中注册它,以启用对 wechatpadpro 消息平台的事件处理

Bug 修复:

  • 更新缺失依赖项错误消息,以使用正确的 pip 安装命令引用 pilk
Original summary in English

Summary by Sourcery

Add support for listening to wechatpadpro platform events and correct the pilk dependency error message

New Features:

  • Add WECHATPADPRO to PlatformAdapterType and register it in the adapter name mapping to enable event handling for the wechatpadpro message platform

Bug Fixes:

  • Update the missing dependency error message to reference pilk with the correct pip install command

增加监听wechatpadpro消息平台的事件
Copy link
Contributor

sourcery-ai bot commented Jul 2, 2025

## 审查者指南

此 PR 引入了对 WechatPadPro 消息平台的支持,通过扩展 PlatformAdapterType 枚举及其名称映射,并且更新了依赖安装提示以引用正确的 pilk 包。

#### 更新后的 PlatformAdapterType 枚举和适配器映射的类图

```mermaid
classDiagram
    class PlatformAdapterType {
        <<enum.Flag>>
        AIOCQHTTP
        QQOFFICIAL
        VCHAT
        GEWECHAT
        TELEGRAM
        WECOM
        LARK
        WECHATPADPRO
        ALL
    }
    class ADAPTER_NAME_2_TYPE {
        "aiocqhttp": PlatformAdapterType.AIOCQHTTP
        "qqofficial": PlatformAdapterType.QQOFFICIAL
        "vchat": PlatformAdapterType.VCHAT
        "gewechat": PlatformAdapterType.GEWECHAT
        "telegram": PlatformAdapterType.TELEGRAM
        "wecom": PlatformAdapterType.WECOM
        "lark": PlatformAdapterType.LARK
        "wechatpadpro": PlatformAdapterType.WECHATPADPRO
    }

更新后的 audio_to_tencent_silk_base64 异常处理的类图

classDiagram
    class audio_to_tencent_silk_base64 {
        +async audio_to_tencent_silk_base64(audio_path: str) -> tuple[str, float]
    }
    class Exception {
    }
    audio_to_tencent_silk_base64 ..> Exception : raises
Loading

文件级别变更

变更 详情 文件
增加了对 WechatPadPro 消息平台的支持
  • 引入 WECHATPADPRO 枚举标志
  • 在 ALL 组合中包含 WECHATPADPRO
  • 将 'wechatpadpro' 映射到 PlatformAdapterType.WECHATPADPRO
astrbot/core/star/filter/platform_adapter_type.py
修正了 pilk 的依赖安装提示
  • 更新异常消息以引用 pilk 而不是 pysilk
astrbot/core/utils/tencent_record_helper.py

可能相关的问题

  • #0: 此 PR 增加了对 wechatpadpro 平台和事件监听的支持,这是实现其连接问题通知所必需的。

提示和命令

与 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

This PR introduces support for the WechatPadPro message platform by extending the PlatformAdapterType enum and its name mapping, and also updates the dependency installation prompt to reference the correct pilk package.

Class diagram for updated PlatformAdapterType enum and adapter mapping

classDiagram
    class PlatformAdapterType {
        <<enum.Flag>>
        AIOCQHTTP
        QQOFFICIAL
        VCHAT
        GEWECHAT
        TELEGRAM
        WECOM
        LARK
        WECHATPADPRO
        ALL
    }
    class ADAPTER_NAME_2_TYPE {
        "aiocqhttp": PlatformAdapterType.AIOCQHTTP
        "qqofficial": PlatformAdapterType.QQOFFICIAL
        "vchat": PlatformAdapterType.VCHAT
        "gewechat": PlatformAdapterType.GEWECHAT
        "telegram": PlatformAdapterType.TELEGRAM
        "wecom": PlatformAdapterType.WECOM
        "lark": PlatformAdapterType.LARK
        "wechatpadpro": PlatformAdapterType.WECHATPADPRO
    }
Loading

Class diagram for updated audio_to_tencent_silk_base64 exception handling

classDiagram
    class audio_to_tencent_silk_base64 {
        +async audio_to_tencent_silk_base64(audio_path: str) -> tuple[str, float]
    }
    class Exception {
    }
    audio_to_tencent_silk_base64 ..> Exception : raises
Loading

File-Level Changes

Change Details Files
Added support for the WechatPadPro message platform
  • Introduce WECHATPADPRO enum flag
  • Include WECHATPADPRO in the ALL combination
  • Map 'wechatpadpro' to PlatformAdapterType.WECHATPADPRO
astrbot/core/star/filter/platform_adapter_type.py
Corrected the dependency installation hint for pilk
  • Update exception message to reference pilk instead of pysilk
astrbot/core/utils/tencent_record_helper.py

Possibly linked issues

  • #0: The PR adds support for the wechatpadpro platform and event listening, which is required to implement notifications for its connection issues.

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

@diudiu62 - 我已经查看了你的更改,它们看起来很棒!


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

Hey @diudiu62 - I've reviewed your changes and they look great!


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.

@@ -117,7 +117,7 @@ async def audio_to_tencent_silk_base64(audio_path: str) -> tuple[str, float]:
try:
import pilk
except ImportError as e:
raise Exception("未安装 pysilk,请执行: pip install pysilk") from e
raise Exception("未安装 pilk: pip install pilk") from e
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): 提出一个特定的错误,而不是通用的 ExceptionBaseException (raise-specific-error)

解释如果一段代码引发一个特定的异常类型, 而不是通用的 [`BaseException`](https://docs.python.org/3/library/exceptions.html#BaseException) 或 [`Exception`](https://docs.python.org/3/library/exceptions.html#Exception), 调用代码可以:
  • 获取更多关于错误类型的信息
  • 为其定义特定的异常处理

这样,代码的调用者可以适当地处理错误。

您如何解决这个问题?

因此,与其让代码引发 ExceptionBaseException,例如

if incorrect_input(value):
    raise Exception("输入不正确")

您可以让代码引发一个特定的错误,例如

if incorrect_input(value):
    raise ValueError("输入不正确")

或者

class IncorrectInputError(Exception):
    pass


if incorrect_input(value):
    raise IncorrectInputError("输入不正确")
Original comment in English

issue (code-quality): Raise a specific error instead of the general Exception or BaseException (raise-specific-error)

ExplanationIf a piece of code raises a specific exception type rather than the generic [`BaseException`](https://docs.python.org/3/library/exceptions.html#BaseException) or [`Exception`](https://docs.python.org/3/library/exceptions.html#Exception), the calling code can:
  • get more information about what type of error it is
  • define specific exception handling for it

This way, callers of the code can handle the error appropriately.

How can you solve this?

So instead of having code raising Exception or BaseException like

if incorrect_input(value):
    raise Exception("The input is incorrect")

you can have code raising a specific error like

if incorrect_input(value):
    raise ValueError("The input is incorrect")

or

class IncorrectInputError(Exception):
    pass


if incorrect_input(value):
    raise IncorrectInputError("The input is incorrect")

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