fix(line): map LINE mentions to At elements so the at-bot rule works - #2478
Merged
RockChinQ merged 1 commit intoAug 27, 2026
Merged
Conversation
The LINE adapter passed text through as a single Plain component, ignoring the mention payload (mentions[].index/length/isSelf) that the Line Messaging API includes in the webhook. As a result: - At(target=bot_account_id) never appeared in the message chain, so the 'at-bot' group respond rule silently dropped every @bot mention. - The bot only replied when the message happened to match the prefix rule (e.g. starting with 'ai'). Now LINEMessageConverter reads message.message.mention and builds the chain per mention position: - Bot mention (isSelf) -> At(target=bot_account_id) so AtBotRule matches the same way as other adapters (dingtalk/lark etc.). - Other mentions -> At(target=<line user id>, display=<mention text>). At.__str__ already prepends '@', so the display text carries no double '@' and the rendered text (prefix/regexp rules, quotes, session context) is byte-identical to before. - Missing/out-of-bounds mentions are skipped defensively. target2yiri becomes an instance method (like wechatpad/aiocqhttp) so the converters can hold bot_account_id; LINEAdapter passes it in from its own config.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
RockChinQ
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The LINE adapter never parsed
message.mentions: the full text (includingthe
@BotNamechip text) went into a singlePlaincomponent. As a result,the
at: truegroup respond rule could never match on LINE —atbot.pylooks for an
Atelement whosetargetequalsbot_account_id, but theadapter produced no
Atelements at all.Users whose bot name is not a configured prefix therefore had to rely on
prefix/regexp rules to get the bot to respond to a LINE group @-mention, and
there was no log of the drop (the message is silently interrupted).
This PR maps LINE mentions to
Atelements:mentionee.is_self) →At(target=bot_account_id)— matches the existing
at-botrule directly;At(target=user_id, display=name)— the@nametext is preserved for prefix/regexp rules (At.__str__()renders@{display}, anddisplayis already@-stripped, so no double@).The text around mentions is split by
mentionee.index/length(LINEguarantees
text[index:index+length] == '@name'); malformed or out-of-rangemention positions are skipped and the remainder falls back to plain text.
No-mention messages, images, and other message types are unchanged.
Related
Same area as #2398 (LINE group session identity); complements it — that one
fixed which session a group message goes to, this one fixes whether the
group message triggers a response at all.
Test Plan
tests/unit_tests/platform/test_line_session_identity.py:At(target=bot_account_id)(theat-botrule case)At(target=user_id, display=name)uv run pytest tests/unit_tests/→ 2803 passeduv run ruff check/ruff format --checkclean