feat: 添加简报收集器功能
All checks were successful
Egg CI/CD / build-image (push) Successful in 22s
Egg CI/CD / deploy (push) Successful in 24s

This commit is contained in:
zhaoyingbo 2024-05-17 13:27:03 +00:00
parent ef3cb5855f
commit c2fcd6387d
2 changed files with 38 additions and 23 deletions

View File

@ -62,33 +62,48 @@ const filterIllegalMsg = (body: LarkMessageEvent) => {
return false;
};
const manageCMDMsg = async (body: LarkMessageEvent) => {
const manageCIMsg = async (chatId: string) => {
lark.sendMsg("chat_id", chatId, "interactive", await fetchCIMonitor());
};
const manageReportMsg = async (chatId: string, msg: string) => {
lark.sendMsg(
"chat_id",
chatId,
"interactive",
await fetchReportCollector(msg)
);
};
const manageIdMsg = async (chatId: string) => {
const content = JSON.stringify({
type: "template",
data: {
config: {
update_multi: true,
},
template_id: "ctp_AAi3NnHb6zgK",
template_variable: {
chat_id: chatId,
},
},
});
lark.sendMsg("chat_id", chatId, "interactive", content);
};
const manageCMDMsg = (body: LarkMessageEvent) => {
const text = getMsgText(body);
const chatId = getChatId(body);
let msgContent = "";
if (text === "/id") {
msgContent = JSON.stringify({
type: "template",
data: {
config: {
update_multi: true,
},
template_id: "ctp_AAi3NnHb6zgK",
template_variable: {
chat_id: chatId,
},
},
});
manageIdMsg(chatId);
return true;
}
if (text === "/ci") {
msgContent = await fetchCIMonitor();
manageCIMsg(chatId);
return true;
}
if (text.includes("share") && text.includes("简报")) {
msgContent = await fetchReportCollector(text);
}
if (msgContent) {
await lark.sendMsg("chat_id", chatId, "interactive", msgContent);
manageReportMsg(chatId, text);
return true;
}
return false;
@ -117,7 +132,7 @@ const replyGuideMsg = async (body: LarkMessageEvent) => {
* Event消息
* @param {LarkUserAction} body
*/
export const manageEventMsg = async (body: LarkMessageEvent) => {
export const manageEventMsg = (body: LarkMessageEvent) => {
// 过滤非Event消息
if (!getIsEventMsg(body)) {
return false;
@ -127,7 +142,7 @@ export const manageEventMsg = async (body: LarkMessageEvent) => {
return true;
}
// 处理命令消息
if (await manageCMDMsg(body)) {
if (manageCMDMsg(body)) {
return true;
}
// 返回引导消息

View File

@ -8,7 +8,7 @@ export const manageBotReq = async (req: Request) => {
return Response.json({ challenge: body?.challenge });
}
// 处理Event消息
if (await manageEventMsg(body)) return new Response("success");
if (manageEventMsg(body)) return new Response("success");
// 处理Action消息
if (manageActionMsg(body)) return new Response("success");
return new Response("hello, glade to see you!");