Skip to content

fix: fetch_emoji_like 兼容 LLBot#119

Open
jmt059 wants to merge 1 commit intoZhalslar:mainfrom
jmt059:fix/fetch-emoji-like-llbot-compat
Open

fix: fetch_emoji_like 兼容 LLBot#119
jmt059 wants to merge 1 commit intoZhalslar:mainfrom
jmt059:fix/fetch-emoji-like-llbot-compat

Conversation

@jmt059
Copy link
Copy Markdown

@jmt059 jmt059 commented May 4, 2026

问题

仲裁器 (EmojiLikeArbiter) 的 fetch_emoji_like 调用使用了 NapCat 风格的 camelCase 参数名 (emojiId),但 LLBot (LuckyLilliaBot)fetch_emoji_like 使用 snake_case 参数名 (emoji_id)。

LLBot 的 payload schema (源码):

payloadSchema = {
    emoji_id: string().required(),  // snake_case
    message_id: union([Number, String]).required(),
    count: union([Number, String]).default(20)
}

当 Bot 通过 LLBot 连接时,emoji_id 缺失导致 schema 验证失败,异常被 except Exception 静默捕获,_fetch_users 始终返回空列表。结果:仲裁完全失效,所有 Bot 都认为自己胜出,重复解析同一链接。

set_msg_emoji_like 不受影响(NapCat 和 LLBot 都接受 emoji_id)。

修复

同时传递两种参数名(emoji_id + emojiId),各实现取所需、忽略未知参数:

resp = await bot.fetch_emoji_like(
    message_id=message_id,
    emoji_id=str(emoji_id),   # LLBot
    emojiId=str(emoji_id),    # NapCat
    emojiType=emoji_type,     # NapCat
    count=20,
)

验证

  • NapCat (mlikiowa/napcat-docker:latest) ✅ 仲裁正常
  • LLBot (linyuchen/llbot:7.12.11) ✅ 仲裁正常(修复前失效)

Summary by Sourcery

Bug Fixes:

  • 修复由于 fetch_emoji_like 参数名称不匹配,导致在使用 LLBot 时表情符号类似仲裁失败的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix emoji-like arbitration failing with LLBot due to mismatched fetch_emoji_like parameter names.

LLBot 的 fetch_emoji_like 使用 snake_case 参数名 (emoji_id),
而 NapCat 使用 camelCase (emojiId)。当前代码只传了 emojiId,
导致 LLBot 因缺少必需参数 emoji_id 而验证失败,异常被静默捕获,
仲裁机制完全失效——所有 Bot 都认为自己胜出,重复解析。

同时传递两种参数名,各实现取所需、忽略未知参数。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 4, 2026 06:04
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 4, 2026

审阅者指南(在小型 PR 上折叠)

审阅者指南

调整 EmojiLikeArbiter 的 _fetch_users,使其在调用 fetch_emoji_like 时同时传递 snake_case 和 camelCase 参数(以及显式的 count),以便同时兼容 LLBot 和 NapCat 的实现,从而恢复正确的仲裁行为。

EmojiLikeArbiter _fetch_users 调用 fetch_emoji_like 的时序图

sequenceDiagram
    participant EmojiLikeArbiter
    participant Bot
    participant Platform

    EmojiLikeArbiter->>Bot: fetch_emoji_like(message_id, emoji_id, emojiId, emojiType, count)
    Note over EmojiLikeArbiter,Bot: Both snake_case and camelCase params are sent

    alt NapCat implementation
        Bot->>Platform: fetch_emoji_like(message_id, emojiId, emojiType, count)
        Platform-->>Bot: emoji_like_users
        Bot-->>EmojiLikeArbiter: emoji_like_users
    else LLBot implementation
        Bot->>Platform: fetch_emoji_like(message_id, emoji_id, count)
        Platform-->>Bot: emoji_like_users
        Bot-->>EmojiLikeArbiter: emoji_like_users
    end

    EmojiLikeArbiter->>EmojiLikeArbiter: use emoji_like_users for arbitration
Loading

EmojiLikeArbiter _fetch_users 参数变更的类图

classDiagram
    class EmojiLikeArbiter {
        +_fetch_users(bot, message_id, emoji_id, emoji_type) async
    }

    class Bot {
        +fetch_emoji_like(message_id, emoji_id, emojiId, emojiType, count) async
    }

    EmojiLikeArbiter --> Bot : uses
Loading

文件级变更

变更 详情 文件
更新表情点赞(emoji-like)获取逻辑,以同时兼容 LLBot 和 NapCat 的 fetch_emoji_like 参数约定。
  • 在调用 fetch_emoji_like 时添加 snake_case 的 emoji_id 参数,以确保 LLBot 的 schema 校验通过。
  • 保留现有的 camelCase 参数 emojiId 和 emojiType,以保持对 NapCat 的兼容性。
  • 显式传入固定的 count=20 参数,而不是依赖适配器默认值。
  • 在失败时像之前一样返回空列表,从而保持现有的异常行为。
core/arbiter.py

提示与命令

与 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 (collapsed on small PRs)

Reviewer's Guide

Adjusts EmojiLikeArbiter’s _fetch_users to pass both snake_case and camelCase parameters (and an explicit count) to fetch_emoji_like so it works with both LLBot and NapCat implementations, restoring proper arbitration behavior.

Sequence diagram for EmojiLikeArbiter _fetch_users calling fetch_emoji_like

sequenceDiagram
    participant EmojiLikeArbiter
    participant Bot
    participant Platform

    EmojiLikeArbiter->>Bot: fetch_emoji_like(message_id, emoji_id, emojiId, emojiType, count)
    Note over EmojiLikeArbiter,Bot: Both snake_case and camelCase params are sent

    alt NapCat implementation
        Bot->>Platform: fetch_emoji_like(message_id, emojiId, emojiType, count)
        Platform-->>Bot: emoji_like_users
        Bot-->>EmojiLikeArbiter: emoji_like_users
    else LLBot implementation
        Bot->>Platform: fetch_emoji_like(message_id, emoji_id, count)
        Platform-->>Bot: emoji_like_users
        Bot-->>EmojiLikeArbiter: emoji_like_users
    end

    EmojiLikeArbiter->>EmojiLikeArbiter: use emoji_like_users for arbitration
Loading

Class diagram for EmojiLikeArbiter _fetch_users parameter changes

classDiagram
    class EmojiLikeArbiter {
        +_fetch_users(bot, message_id, emoji_id, emoji_type) async
    }

    class Bot {
        +fetch_emoji_like(message_id, emoji_id, emojiId, emojiType, count) async
    }

    EmojiLikeArbiter --> Bot : uses
Loading

File-Level Changes

Change Details Files
Update emoji-like fetching to be compatible with both LLBot and NapCat fetch_emoji_like parameter conventions.
  • Add snake_case emoji_id argument when calling fetch_emoji_like so LLBot schema validation succeeds.
  • Keep existing camelCase emojiId and emojiType arguments for NapCat compatibility.
  • Pass a fixed count=20 parameter explicitly instead of relying on adapter defaults.
  • Handle failures by returning an empty list as before, preserving the existing exception behavior.
core/arbiter.py

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 - 我在这里给出一些整体性的反馈:

  • 捕获一个宽泛的 Exception 并返回空列表会让调试失败变得困难;建议至少记录(log)异常,或者收窄要捕获的异常类型,这样意外的 schema 变更可以更明显地暴露出来。
  • 目前 LLBot/NapCat 的兼容分支是通过双参数名以内联方式编码的;建议把这部分兼容逻辑抽取出来(例如封装到一个 helper 或 adapter 中),这样未来的 OneBot 实现或参数变更可以在一个集中位置处理,而不是让协议细节散落在 arbiter 的各处。
AI Agent 提示词
Please address the comments from this code review:

## Overall Comments
- Catching a broad `Exception` and returning an empty list makes debugging failures difficult; consider at least logging the exception or narrowing the exception types so unexpected schema changes surface more visibly.
- The LLBot/NapCat compatibility branching is currently encoded inline via dual parameter names; consider encapsulating this compatibility logic (e.g., in a helper or adapter) so future OneBot implementations or parameter changes can be handled in a single place instead of scattering protocol quirks through the arbiter.

Sourcery 对开源项目是免费的——如果你觉得我们的 Review 有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English

Hey - I've left some high level feedback:

  • Catching a broad Exception and returning an empty list makes debugging failures difficult; consider at least logging the exception or narrowing the exception types so unexpected schema changes surface more visibly.
  • The LLBot/NapCat compatibility branching is currently encoded inline via dual parameter names; consider encapsulating this compatibility logic (e.g., in a helper or adapter) so future OneBot implementations or parameter changes can be handled in a single place instead of scattering protocol quirks through the arbiter.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Catching a broad `Exception` and returning an empty list makes debugging failures difficult; consider at least logging the exception or narrowing the exception types so unexpected schema changes surface more visibly.
- The LLBot/NapCat compatibility branching is currently encoded inline via dual parameter names; consider encapsulating this compatibility logic (e.g., in a helper or adapter) so future OneBot implementations or parameter changes can be handled in a single place instead of scattering protocol quirks through the arbiter.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes EmojiLikeArbiter compatibility with LLBot by aligning the fetch_emoji_like request payload with both supported parameter naming styles, so the existing cross-bot arbitration logic works consistently on aiocqhttp-based QQ bot implementations.

Changes:

  • Update fetch_emoji_like calls to send both emoji_id and emojiId so LLBot and NapCat can each accept the field they expect.
  • Add an explicit count=20 parameter to the emoji-like fetch request.
  • Keep the arbiter’s existing behavior unchanged aside from restoring compatibility for LLBot-backed bots.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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