File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed
modules/tool/packages/feishu/src Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -13,31 +13,22 @@ export const OutputType = z.object({
13
13
} )
14
14
} ) ;
15
15
16
+ // support json or plaintext:
17
+ // if json, just return it (for supporting customized message)
18
+ // if plaintext, wrap it with json
16
19
function format ( content : string ) {
17
20
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 ) ;
32
22
} catch ( err ) {
33
23
return {
34
24
msg_type : 'text' ,
35
25
content : {
36
- text : err
26
+ text : content
37
27
}
38
28
} ;
39
29
}
40
30
}
31
+
41
32
export async function tool ( props : z . infer < typeof InputType > ) : Promise < z . infer < typeof OutputType > > {
42
33
const { content, hook_url } = props ;
43
34
const data = format ( content ) ;
You can’t perform that action at this time.
0 commit comments