@@ -38,6 +38,7 @@ async function sendMessageToWeComBot(
38
38
break
39
39
case MessageType . MARKDOWN :
40
40
payload = { msgtype : 'markdown' , markdown : { content : message } }
41
+ core . debug ( `payload: ${ payload } ` )
41
42
break
42
43
case MessageType . IMAGE :
43
44
// message should be base64 encoded image
@@ -66,40 +67,36 @@ async function sendMessageToWeComBot(
66
67
}
67
68
68
69
async function run ( ) {
69
- try {
70
- const wxWorkBotKey = core . getInput ( 'key' , { required : true } )
71
- if ( ! validateBotKey ( wxWorkBotKey ) ) {
72
- core . setFailed ( 'Invalid or missing wecom bot hook key.' )
73
- return
74
- }
75
-
76
- // 获取消息内容和消息类型
77
- const msgContent = core . getInput ( 'content' , { required : true } )
78
- const msgType = core . getInput ( 'type' , {
79
- required : true
80
- } ) as MessageTypeValue
70
+ const wxWorkBotKey = core . getInput ( 'key' , { required : true } )
71
+ if ( ! validateBotKey ( wxWorkBotKey ) ) {
72
+ core . setFailed ( 'Invalid or missing wecom bot hook key.' )
73
+ return
74
+ }
81
75
82
- // 验证消息类型
83
- if (
84
- ! [
85
- MessageType . TEXT ,
86
- MessageType . IMAGE ,
87
- MessageType . MARKDOWN ,
88
- MessageType . NEWS ,
89
- MessageType . TEMPLATE_CARD
90
- ] . includes ( msgType )
91
- ) {
92
- core . setFailed (
93
- 'Invalid message type. Allowed types are "text", "markdown", "image", and "news".'
94
- )
95
- return
96
- }
76
+ // 获取消息内容和消息类型
77
+ const msgContent = core . getInput ( 'content' , { required : true } )
78
+ const msgType = core . getInput ( 'type' , {
79
+ required : true
80
+ } ) as MessageTypeValue
97
81
98
- // 发送消息
99
- await sendMessageToWeComBot ( wxWorkBotKey , msgType , msgContent )
100
- } catch ( error : any ) {
101
- core . setFailed ( `An unexpected error occurred: ${ error . message } ` )
82
+ // 验证消息类型
83
+ if (
84
+ ! [
85
+ MessageType . TEXT ,
86
+ MessageType . IMAGE ,
87
+ MessageType . MARKDOWN ,
88
+ MessageType . NEWS ,
89
+ MessageType . TEMPLATE_CARD
90
+ ] . includes ( msgType )
91
+ ) {
92
+ core . setFailed (
93
+ 'Invalid message type. Allowed types are "text", "markdown", "image", and "news".'
94
+ )
95
+ return
102
96
}
97
+
98
+ // 发送消息
99
+ await sendMessageToWeComBot ( wxWorkBotKey , msgType , msgContent )
103
100
}
104
101
105
102
run ( )
0 commit comments