Commit 4b0a134f authored by ml's avatar ml

报警机器人消息相关调整

parent c7bac0ff
let {
debug,
logger
} = require('@madex/ex-js-public');
const {
larkRobotUtils: LarkRobotUtils,
} = require("@madex/ex-js-common")
let config = require('../../config');
let axios = require('axios');
debug = config.env === "development";
let COMMON_KEY = "9e06e260-6c2f-49d4-98b4-e08ef096f6f5";
//测试
/**
* Lark 地址
*/
let LARK_URL_PRE = "https://open.larksuite.com/open-apis/bot/v2/hook/";
/**
* 生产:pro
*/
let COMMON_KEY = "d9f2dc6e-52cf-4933-92f1-dab9c249aa28";
/**
* 测试:dev
*/
if (debug) {
COMMON_KEY = "9e06e260-6c2f-49d4-98b4-e08ef096f6f5";
COMMON_KEY = "d98c9942-ff6f-4e71-a77f-41647ff19ff0";
}
export const ROBOT_KEYS = {
COMMON_KEY: COMMON_KEY
}
......@@ -27,7 +38,9 @@ export const ROBOT_KEYS = {
* @param _func_name_ 报错方法(可选)
*/
export const sendRobotMessage = async function (url: string, content: any, _func_name_?: string) {
if (!_func_name_) {
_func_name_ = '';
}
if (typeof content != 'string') {
if (content && content.sql) {
content = `backend._func_name_ ${_func_name_}, ${content.sql}`;
......@@ -55,5 +68,17 @@ export const sendRobotMessage = async function (url: string, content: any, _func
async function doSend(url: string, content: any) {
logger.info('robot message', url, content);
await LarkRobotUtils.sendTextSimple(url, content).catch()
let URL = LARK_URL_PRE + url;
try {
let response = await axios.post(URL, {
msg_type: "text",
content: { text: content }
});
if (response && response.data) {
return response.data
}
}
catch (e) {
logger.error('robot send error', URL, content);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment