Skip to content

Commit 31d557c

Browse files
committed
fix: xx
1 parent aca982b commit 31d557c

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

src/main.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async function sendMessageToWeComBot(
3838
break
3939
case MessageType.MARKDOWN:
4040
payload = {msgtype: 'markdown', markdown: {content: message}}
41+
core.debug(`payload: ${payload}`)
4142
break
4243
case MessageType.IMAGE:
4344
// message should be base64 encoded image
@@ -66,40 +67,36 @@ async function sendMessageToWeComBot(
6667
}
6768

6869
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+
}
8175

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
9781

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
10296
}
97+
98+
// 发送消息
99+
await sendMessageToWeComBot(wxWorkBotKey, msgType, msgContent)
103100
}
104101

105102
run()

0 commit comments

Comments
 (0)