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:
1 parent
d804a3b2e0
commit
d2a67cb560
4 files changed
+35
-6
No files matched your search
@@ -95,7 +95,13 @@ function renderSegment(type: string, data: Record<string, unknown>): string {
|
||||
case 'reply': return `[回复:${data.id ?? ''}]`;
|
||||
case 'record': return '[语音]';
|
||||
case 'video': return '[视频]';
|
||||
case 'file': return data.file ? `[文件:${truncate(String(data.file), 20)}]` : '[文件]';
|
||||
case 'file': {
|
||||
// OneBot file segments carry the filename under `data.name`
|
||||
// (see to-segment.ts). Keep `data.file` as a fallback for any
|
||||
// upstream that still uses the older field name.
|
||||
const fileName = data.name ?? data.file;
|
||||
return fileName ? `[文件:${truncate(String(fileName), 20)}]` : '[文件]';
|
||||
}
|
||||
case 'json': return '[JSON]';
|
||||
case 'xml': return '[XML]';
|
||||
case 'markdown': return '[Markdown]';
|
||||
|
||||
Reference in new issue
Block a user