feat: 支持CI
All checks were successful
Egg CI/CD / build-image (push) Successful in 26s
Egg CI/CD / deploy (push) Successful in 20s

This commit is contained in:
zhaoyingbo 2024-03-07 12:08:02 +00:00
parent c562c24689
commit 747cd8b7e4
2 changed files with 41 additions and 10 deletions

View File

@ -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
View File

@ -0,0 +1 @@
export const fetchCIMonitor = () => fetch("https://ci-monitor.xiaomiwh.cn");