feat: 支持CI
This commit is contained in:
parent
c562c24689
commit
747cd8b7e4
@ -1,3 +1,4 @@
|
||||
import { fetchCIMonitor } from "../../service";
|
||||
import { sendMsg } from "../../utils/sendMsg";
|
||||
|
||||
/**
|
||||
@ -77,23 +78,52 @@ const filterIllegalMsg = (body: LarkMessageEvent) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 过滤出info指令
|
||||
* 处理info指令
|
||||
* @param chatId 聊天流Id
|
||||
*/
|
||||
const manageInfoCommand = (chatId: string) => {
|
||||
const content = JSON.stringify({ text: `chatId: ${chatId}` });
|
||||
sendMsg("chat_id", chatId, "text", content);
|
||||
};
|
||||
|
||||
/**
|
||||
* 过滤出指令
|
||||
* @param {LarkMessageEvent} body
|
||||
* @returns {boolean} 是否为info指令
|
||||
*/
|
||||
const filterGetInfoCommand = (body: LarkMessageEvent) => {
|
||||
const filterCommand = (body: LarkMessageEvent) => {
|
||||
const chatId = getChatId(body);
|
||||
const text = getMsgText(body);
|
||||
if (text !== "info") return false;
|
||||
const content = JSON.stringify({ text: JSON.stringify(body) });
|
||||
sendMsg("chat_id", chatId, "text", content);
|
||||
return true;
|
||||
if (text === "info") {
|
||||
manageInfoCommand(chatId);
|
||||
return true;
|
||||
}
|
||||
if (text === "ci") {
|
||||
fetchCIMonitor();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const replyNomalMsg = async (body: LarkMessageEvent) => {
|
||||
const chatId = getChatId(body);
|
||||
const content = JSON.stringify({ text: "指令:info" });
|
||||
sendMsg("chat_id", chatId, "text", content);
|
||||
const content = JSON.stringify({
|
||||
elements: [
|
||||
{
|
||||
tag: "markdown",
|
||||
content: "**目前支持的指令**\n1. info\n2. ci",
|
||||
},
|
||||
],
|
||||
header: {
|
||||
template: "blue",
|
||||
title: {
|
||||
content: "欢迎使用小煎蛋 ₍ᐢ..ᐢ₎♡",
|
||||
tag: "plain_text",
|
||||
},
|
||||
},
|
||||
});
|
||||
sendMsg("chat_id", chatId, "interactive", content);
|
||||
};
|
||||
|
||||
export const manageEventMsg = async (body: LarkMessageEvent) => {
|
||||
@ -105,8 +135,8 @@ export const manageEventMsg = async (body: LarkMessageEvent) => {
|
||||
if (filterIllegalMsg(body)) {
|
||||
return true;
|
||||
}
|
||||
// 过滤info指令
|
||||
if (filterGetInfoCommand(body)) {
|
||||
// 过滤指令
|
||||
if (filterCommand(body)) {
|
||||
return true;
|
||||
}
|
||||
// 临时返回消息
|
||||
|
1
service/index.ts
Normal file
1
service/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export const fetchCIMonitor = () => fetch("https://ci-monitor.xiaomiwh.cn");
|
Loading…
x
Reference in New Issue
Block a user