41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
try {
|
|
var params = JSON.parse(value);
|
|
var response;
|
|
request = new HttpRequest(),
|
|
data = {
|
|
"msg_type": "interactive",
|
|
"card": {
|
|
"type": "template",
|
|
"data": {
|
|
"template_id": "AAqBcOkbPmfUZ",
|
|
"template_version_name": "1.0.3",
|
|
"template_variable": {
|
|
"appName": "Zabbix",
|
|
"msg": params.Message,
|
|
},
|
|
}
|
|
}
|
|
};
|
|
|
|
request.addHeader('Content-Type: application/json');
|
|
|
|
Zabbix.log(4, '[ Feishu Webhook ] Sending request.');
|
|
|
|
response = request.post("https://open.feishu.cn/open-apis/bot/v2/hook/48944500-477a-4647-a7e0-c56c43bee263", JSON.stringify(data));
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
var message = 'Request failed with status code ' + request.getStatus();
|
|
|
|
if (response) {
|
|
message += ': ' + response;
|
|
}
|
|
throw message + '. Check debug log for more information.';
|
|
}
|
|
|
|
|
|
return 'OK';
|
|
}
|
|
catch (error) {
|
|
Zabbix.log(3, '[ BrevisOne Webhook ] ERROR: ' + error);
|
|
throw 'Sending failed: ' + error;
|
|
} |