47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import type { LarkEvent } from "@egg/lark-msg-tool"
|
|
import { NetToolBase } from "@egg/net-tool"
|
|
|
|
class AttachService extends NetToolBase {
|
|
protected hostMap: Record<string, string> = {
|
|
dev: "https://lark-egg-preview.ai.xiaomi.com",
|
|
preview: "https://lark-egg-preview.ai.xiaomi.com",
|
|
production: "https://lark-egg.ai.xiaomi.com",
|
|
}
|
|
|
|
/**
|
|
* 监控CI状态
|
|
* @param {string} chat_id - 聊天ID。
|
|
* @returns {Promise<string>} 返回CI监控结果。
|
|
*/
|
|
async ciMonitor(chat_id: string) {
|
|
const URL = `https://lark-egg.ai.xiaomi.com/gitlab_monitor/ci?chat_id=${chat_id}`
|
|
return this.get(URL).catch(() => "")
|
|
}
|
|
|
|
/**
|
|
* 收集报告数据
|
|
* @param {LarkEvent.Data} body - 报告数据。
|
|
* @returns {Promise<string>} 返回报告收集结果。
|
|
*/
|
|
async reportCollector(body: LarkEvent.Data) {
|
|
const URL = "https://report.imoaix.cn/report"
|
|
return this.post(URL, body).catch(() => "")
|
|
}
|
|
|
|
/**
|
|
* 代理MiChat事件
|
|
* @param {LarkEvent.Data} body - 事件数据。
|
|
* @returns {Promise<void>} 返回空。
|
|
*/
|
|
async proxyMiChatEvent(body: LarkEvent.Data) {
|
|
const hostList = ["michat-staging.ai.srv", "michat.ai.srv"]
|
|
const path = "/api/v1/bypass/robot_event_callback"
|
|
for (const host of hostList) {
|
|
const URL = `http://${host}${path}`
|
|
await this.post(URL, body).catch(() => "")
|
|
}
|
|
}
|
|
}
|
|
|
|
export default AttachService
|