https://github.com/ByteWebMonitor/byte-monitor-feishu-robot
飞书群增加机器人
复制WebHook地址,创建Secret密钥
包比较简单,主要内容结构飞书文档难找没找到
现在找到了
Send message - Server API - Feishu Open Platform
import Robot = require('byte-monitor-feishu-robot/lib/robot');
import { utilLogger } from './winstonLogUtil';
import { safeJSONStringify } from './objectUtils';
import { FEISSHU_WEBHOOK, FEISSHU_WEBHOOK_SECRET } from '../constant/feishu.rot.constant';
export const TEST_ROT = new Robot(FEISSHU_WEBHOOK, FEISSHU_WEBHOOK_SECRET );
/**
* 发送消息
* @param rot
* @param content
*/
export const sendFeishuBotTxt = async (rot:Robot, content: string) => {
await rot.send({
'msg_type': 'text',
content: {
'text': content
}
}).then(res => {
utilLogger.info(`sendFeishuBot content: ${content} res${safeJSONStringify(res)}}`)
}).catch(err => {
utilLogger.error(`sendFeishuBot content: ${content} error: ${safeJSONStringify(err)}`)
});
}
/**
* 发送富文本消息
*/
export const sendFeishuBotRichText = async (rot:Robot, title: string, texts: any) => {
await rot.sendRickText(title, texts, 'zh_cn').then(res => {
utilLogger.info(`sendFeishuBot content: ${safeJSONStringify(texts)} res${safeJSONStringify(res)}}`)
}).catch(err => {
utilLogger.error(`sendFeishuBot content: ${safeJSONStringify(texts)} error: ${safeJSONStringify(err)}`)
});
}
@Get('send-feishu-bot')
async sendFeishuBot(): Promise<any> {
await sendFeishuBotTxt(TEST_ROT , '测试发送内容 我是汪汪队立大功');
return 'ok';
}