feat: 优化简报收集器请求参数,添加用户Id和chat_id
All checks were successful
Egg CI/CD / build-image (push) Successful in 21s
Egg CI/CD / deploy (push) Successful in 23s

This commit is contained in:
zhaoyingbo 2024-05-21 07:11:57 +00:00
parent bf8df7a1b7
commit 8f469ad28d
3 changed files with 8 additions and 13 deletions

View File

@ -1,5 +1,4 @@
import { sleep } from "bun";
import { fetchCIMonitor } from "../../service";
import { getActionType, getIsActionMsg } from "../../utils/msgTools";
import { LarkUserAction } from "../../types";
import lark from "../../service/lark";
@ -22,7 +21,6 @@ const makeChatIdCard = async (body: LarkUserAction) => {
const ACTION_MAP = {
chat_id: makeChatIdCard,
ci: fetchCIMonitor,
};
/**

View File

@ -67,14 +67,6 @@ const filterIllegalMsg = (body: LarkMessageEvent) => {
return false;
};
/**
* CI监控消息
* @param chatId - chatId
*/
const manageCIMsg = async (chatId: string) => {
lark.sendMsg("chat_id", chatId, "interactive", await fetchCIMonitor());
};
/**
* ID消息
* @param chatId - chatId
@ -108,7 +100,7 @@ const manageCMDMsg = (body: LarkMessageEvent) => {
return true;
}
if (text === "/ci") {
manageCIMsg(chatId);
fetchCIMonitor(chatId);
return true;
}
if (text.includes("share") && text.includes("简报")) {
@ -132,6 +124,9 @@ const replyGuideMsg = async (body: LarkMessageEvent) => {
update_multi: true,
},
template_id: "ctp_AAyVx5R39xU9",
template_variable: {
chat_id: chatId,
},
},
});
await lark.sendMsg("chat_id", chatId, "interactive", content);

View File

@ -1,9 +1,11 @@
/**
* CI
*/
export const fetchCIMonitor = async () => {
export const fetchCIMonitor = async (chat_id: string) => {
try {
const res = await fetch("https://ci-monitor.xiaomiwh.cn/ci");
const res = await fetch(
`https://ci-monitor.xiaomiwh.cn/ci?chat_id=${chat_id}`
);
return ((await res.json()) as string) || "";
} catch {
return "";