25 lines
915 B
JavaScript
25 lines
915 B
JavaScript
|
|
exports.sendText = (token, message) => {
|
|
var dingTalkRobotURL = 'https://oapi.dingtalk.com/robot/send?access_token=' + token;
|
|
var postResult = $$.httpRequest()
|
|
.url(dingTalkRobotURL)
|
|
.addHeader('Content-Type', 'application/json')
|
|
.post(JSON.stringify({
|
|
"msgtype": "text",
|
|
"text": {
|
|
"content": $STR(message)
|
|
}
|
|
}));
|
|
return postResult;
|
|
};
|
|
|
|
exports.sendTextDefault = (message) => {
|
|
var tokenFile = $$.file($$.prop('user.home'), '.component-dingtalkrobot.js.token');
|
|
if (!tokenFile.exists()) {
|
|
println('DingTalk token file not exists: ' + tokenFile);
|
|
return;
|
|
}
|
|
var token = $$.rFile(tokenFile).string().trim();
|
|
sendDingTalkRobotTextMessage(token, message);
|
|
};
|