Skip to content

feat:飞书回复预表情自动删除 - #10223

Open
Edge-HH wants to merge 16 commits into
AstrBotDevs:masterfrom
Edge-HH:master
Open

Edge-HH wants to merge 16 commits into
AstrBotDevs:masterfrom
Edge-HH:master

Conversation

@Edge-HH

@Edge-HH Edge-HH commented Sep 25, 2026 •

Copy link
Copy Markdown

feat:飞书回复预表情自动删除

修复了飞书在启用“[飞书] 启用预回应表情”时,回复完成后不会自动清除预表情的问题
Fixes #8003

Modifications / 改动点

astrbot/core/config/default.py:新增 platform_specific.lark.pre_ack_emoji.auto_remove 配置(默认 true)及 WebUI 元数据
astrbot/core/platform/astr_message_event.py:react() 返回 reaction id,新增 remove_reaction()
astrbot/core/platform/sources/lark/lark_event.py:创建表情回应时返回 reaction_id;无法取得 id 时按表情与机器人操作者解析并删除
astrbot/core/pipeline/preprocess_stage/stage.py:开启自动删除时记录 _pre_ack_reaction_id
astrbot/core/pipeline/scheduler.py:事件处理结束时删除预回应表情
dashboard/src/i18n/locales/{zh-CN,en-US,ja-JP,ru-RU}/features/config-metadata.json:四语言文案
docs/zh|en/dev/astrbot-config.md:补充配置说明
tests/test_lark_pre_ack_auto_remove.py:单元测试

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

image image

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。

  • 📚 I checked the affected WebUI instructions and screenshots in docs/zh and docs/en against the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog.
    / 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新 docs/zh 和 docs/en 的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Automatically remove Feishu pre-response reactions after processing while allowing the behavior to be configured.

New Features:

  • Add configurable automatic removal of Feishu/Lark pre-response reactions after message processing completes.

Bug Fixes:

  • Ensure Lark pre-response reactions are removed reliably even when processing fails or the reaction API does not return an identifier.

Enhancements:

  • Extend platform reaction handling to support reaction identifiers and removal, including fallback lookup by emoji and operator.

Documentation:

  • Document the Lark pre-response reaction auto-removal setting in English and Chinese configuration guides.

Tests:

  • Add comprehensive tests covering reaction creation, removal, fallback resolution, preprocessing, and scheduler cleanup.

Chores:

  • Add localized WebUI metadata for the new Lark reaction setting.

Edge-HH and others added 13 commits September 23, 2026 22:51
- Match reaction operator by app_id or open_id: reactions created with a
  tenant_access_token are reported with operator_type=app, so the previous
  open_id-only comparison never matched and the reaction was left behind.
- Request ListMessageReaction with user_id_type=open_id and page through
  results instead of only reading the first page.
- Track the pre-ack reaction under a single PRE_ACK_REACTION extras key as
  a (reaction_id, emoji) tuple.
- Drop the auto_remove option: pre-ack reactions are always removed after
  processing, per the issue request. Sync config metadata in 4 locales and
  docs/zh|en.
- Restore cfg.get("enable", False) semantics for pre-ack enable checks.
- Cover scheduler happy path, delete-failure fallback and pagination in
  tests; share test scaffolding helpers.
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="astrbot/core/platform/sources/lark/lark_event.py" line_range="1072" />
<code_context>
+            )
+            if page_token:
+                builder = builder.page_token(page_token)
+            response = await self.bot.im.v1.message_reaction.alist(builder.build())
+            if not response.success() or not response.data:
+                logger.error(
</code_context>
<issue_to_address>
**issue (bug_risk):** The fallback `alist()` request and the final `adelete()` request are not wrapped inside `remove_reaction()`. A network or SDK exception escapes to `PipelineScheduler`, where it is swallowed after logging, leaving the successfully created pre-ack reaction on the Lark message.

**Triggers:** When the initial deletion by reaction ID fails and the subsequent list or retry-delete request raises an exception.

**Suggested fix:** Catch and log exceptions around the fallback list/delete calls, and apply an explicit retry strategy or return a failure status so cleanup failures are observable.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and when enabled, this change automatically deletes the Lark reaction through the external API, and the fallback lookup could select an existing reaction with the same emoji and operator if creation did not return an ID. Reverting stops future deletions but cannot restore reactions already removed; the default auto-remove policy also provides no failure signal if that decision is wrong.

Blocking findings: astrbot/core/platform/sources/lark/lark_event.py:1072


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread astrbot/core/platform/sources/lark/lark_event.py Outdated

This branch has not been deployed

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

[Bug]飞书回复预表情不会在回复完成后取消

1 participant