Skip to content
This repository was archived by the owner on Oct 9, 2026. It is now read-only.

fix: OneBot reads media and replies in its string message format - #33

Merged
mekjr1 merged 2 commits into
mainfrom
fix/onebot-cq-string-media
Oct 7, 2026
Merged

mekjr1 merged 2 commits into
mainfrom
fix/onebot-cq-string-media

Conversation

@mekjr1

@mekjr1 mekjr1 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

A OneBot implementation can post messages in two formats: an array of segments (the default), or a string with CQ codes, such as see [CQ:image,file=a.png,url=https://...] here, when set to message_post_format: string. For the string format, parseSegments (pkg/channels/onebot/onebot.go) only looked for a mention of the bot. So its pictures, videos, files and voice messages were never downloaded, replies weren't read, and the agent got the CQ codes as text.

cqSegments now splits the string into the array format's segments, undoing OneBot's escapes ([ ] , &), and the same loop reads both formats. Media is downloaded and tagged in place (#21); mentions, replies and faces work as in the array format. CQ codes of other kinds are dropped from the text, as their segments are in the array format.

Tests: TestParseMessageSegments_StringFormat and TestParseSegments_StringFormatReplyAndMention; both fail without the fix.

@mekjr1
mekjr1 force-pushed the fix/onebot-cq-string-media branch from 8bf07d4 to 0518ebd Compare October 7, 2026 19:34
mekjr1 added 2 commits October 7, 2026 13:53
A OneBot implementation set to post messages as a string sends text with CQ codes, such as [CQ:image,file=a.png,url=...]. parseSegments only looked for a mention of the bot in that format, so its media was never downloaded and the agent got the codes as text. The string is now split into the array format's segments, with OneBot's escapes undone, and read the same way.
@mekjr1
mekjr1 force-pushed the fix/onebot-cq-string-media branch from 0518ebd to d3da47a Compare October 7, 2026 19:53
@mekjr1
mekjr1 merged commit 5e80005 into main Oct 7, 2026
12 checks passed
@mekjr1
mekjr1 deleted the fix/onebot-cq-string-media branch October 7, 2026 20:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant