fix(onebot): add canonical fields to file segment and fix log rendering (#94)

* fix(onebot): support inline file url/path in send_group/private_msg

* test(onebot): update file segment parser test for inline url/path support

* fix(onebot): add canonical fields to file segment and fix log rendering
This commit is contained in:
游手好闲的言柒 authored and GitHub committed 2026-06-11 15:40:47 +08:00
1 parent d804a3b2e0
commit d2a67cb560
4 files changed
+35 -6

No files matched your search

+9
View File
@@ -110,6 +110,15 @@ describe('formatMessageSegments', () => {
expect(out).toBe('hi [图片] @12345 @全体成员 [回复:999] [表情] [视频] [语音]');
});
it('renders file segments using data.name (the OneBot field), with data.file fallback', () => {
expect(formatMessageSegments([{ type: 'file', data: { name: '20260606_151113.wav' } }]))
.toBe('[文件:20260606_151113.wav]');
expect(formatMessageSegments([{ type: 'file', data: { file: 'legacy.bin' } }]))
.toBe('[文件:legacy.bin]');
expect(formatMessageSegments([{ type: 'file', data: {} }]))
.toBe('[文件]');
});
it('renders unknown segment types as [type]', () => {
expect(formatMessageSegments([{ type: 'something_new', data: {} }]))
.toBe('[something_new]');