feat: add components
This commit is contained in:
24
components/component-dingtalkrobot-ex.js
Normal file
24
components/component-dingtalkrobot-ex.js
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user