mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-11 10:00:34 +08:00
31 lines
569 B
JavaScript
31 lines
569 B
JavaScript
export function createTextMessage (text) {
|
|
return {
|
|
"dingtalkRequestBody": {
|
|
"msgtype": "text",
|
|
"text": {
|
|
"content": `${text}`
|
|
},
|
|
},
|
|
insertedTime: new Date(),
|
|
}
|
|
}
|
|
|
|
export async function requestDingtalkNotify (dingTalkAccessToken, body) {
|
|
const url = new URL(`https://oapi.dingtalk.com/robot/send`)
|
|
url.searchParams.append(
|
|
'access_token',
|
|
dingTalkAccessToken
|
|
)
|
|
|
|
return await fetch(
|
|
url,
|
|
{
|
|
method: 'post',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body
|
|
}
|
|
)
|
|
}
|