Skip to content

Commit 72876a9

Browse files
authored
fix: feishu tool (#88)
1 parent 5c0cd53 commit 72876a9

File tree

1 file changed

+6
-15
lines changed
  • modules/tool/packages/feishu/src

1 file changed

+6
-15
lines changed

modules/tool/packages/feishu/src/index.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,22 @@ export const OutputType = z.object({
1313
})
1414
});
1515

16+
// support json or plaintext:
17+
// if json, just return it (for supporting customized message)
18+
// if plaintext, wrap it with json
1619
function format(content: string) {
1720
try {
18-
const parseData = JSON.parse(content);
19-
if (typeof parseData === 'object') {
20-
return parseData;
21-
}
22-
addLog.info('Feishu tool format content', {
23-
content,
24-
parseData
25-
});
26-
return {
27-
msg_type: 'text',
28-
content: {
29-
text: content
30-
}
31-
};
21+
return JSON.parse(content);
3222
} catch (err) {
3323
return {
3424
msg_type: 'text',
3525
content: {
36-
text: err
26+
text: content
3727
}
3828
};
3929
}
4030
}
31+
4132
export async function tool(props: z.infer<typeof InputType>): Promise<z.infer<typeof OutputType>> {
4233
const { content, hook_url } = props;
4334
const data = format(content);

0 commit comments

Comments
 (0)