视频网站 阿里云,沈阳企业建站模板,加工厂做网站,wordpress用户权限在哪改message-robot 便于线上异常问题及时发现处理#xff0c;项目中集成企微机器人通知#xff0c;及时接收问题并处理 企微机器人通知工具类
export class MessageRobotUtil {constructor() {}/*** 发送 markdown 消息* param robotKey 机器人 ID* param title 消息标题* param…message-robot 便于线上异常问题及时发现处理项目中集成企微机器人通知及时接收问题并处理 企微机器人通知工具类
export class MessageRobotUtil {constructor() {}/*** 发送 markdown 消息* param robotKey 机器人 ID* param title 消息标题* param items 消息内容*/public sendMarkdownMessage(robotKey: string, title: string, items: Recordstring, string) {const content this.generateMarkdownMessageContent(title, items);this.sendMessage(robotKey, {msgtype: markdown,markdown: { content: content },});}/*** 构建 markdown 消息内容* param title 消息标题* param items 消息内容 键值对* returns*/private generateMarkdownMessageContent(title: string, items: Recordstring, any) {let content ### 【${title}】;content \n;for (const key in items) {content ${key}: font colorwarning${items[key]}/font\n;}return content;}/*** 消息发送* param robotKey 机器人 ID* param message 消息内容*/private sendMessage(robotKey: string, message: Recordstring, any) {// 跟地址 https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key****const url /cgi-bin/webhook/send?key robotKey;fetch(url, {method: POST,headers: {Content-Type: application/json,},body: JSON.stringify(message),});}
}