feat: 优化简报收集器请求参数,添加用户Id和chat_id
This commit is contained in:
parent
bf8df7a1b7
commit
8f469ad28d
@ -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,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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 "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user