feat: 分离小煎蛋和michat的指令
This commit is contained in:
parent
ae759108cf
commit
1153183869
@ -15,7 +15,8 @@ const tempMap = {
|
|||||||
successMsg: "ctp_AA0LgXOkEOPK",
|
successMsg: "ctp_AA0LgXOkEOPK",
|
||||||
errorMsg: "ctp_AA0LgXOkEuqi",
|
errorMsg: "ctp_AA0LgXOkEuqi",
|
||||||
chatId: "ctp_AAi3NnHb6zgK",
|
chatId: "ctp_AAi3NnHb6zgK",
|
||||||
guide: "ctp_AAyVx5R39xU9",
|
eggGuide: "ctp_AAyVx5R39xU9",
|
||||||
|
miChatGuide: "AAqDiiTs4kSN9",
|
||||||
createKVSuccess: "ctp_AA00oqPWPXtG",
|
createKVSuccess: "ctp_AA00oqPWPXtG",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { type LarkBody } from "@egg/lark-msg-tool"
|
import { type LarkBody } from "@egg/lark-msg-tool"
|
||||||
|
|
||||||
|
import tempMap from "../../constant/template"
|
||||||
import db from "../../db"
|
import db from "../../db"
|
||||||
import { Context } from "../../types"
|
import { Context } from "../../types"
|
||||||
import createKVTemp from "../sheet/createKVTemp"
|
import createKVTemp from "../sheet/createKVTemp"
|
||||||
@ -93,14 +94,13 @@ const manageIdMsg = ({
|
|||||||
* 回复引导消息
|
* 回复引导消息
|
||||||
* @param {Context.Data} ctx - 上下文数据
|
* @param {Context.Data} ctx - 上下文数据
|
||||||
*/
|
*/
|
||||||
const manageHelpMsg = ({
|
const manageHelpMsg = (
|
||||||
larkBody: { chatId },
|
{ larkBody: { chatId }, larkCard, larkService }: Context.Data,
|
||||||
larkCard,
|
tempKey: keyof typeof tempMap
|
||||||
larkService,
|
): void => {
|
||||||
}: Context.Data): void => {
|
|
||||||
larkService.message.sendCard2Chat(
|
larkService.message.sendCard2Chat(
|
||||||
chatId,
|
chatId,
|
||||||
larkCard.genTempCard("guide", { chat_id: chatId }) as string
|
larkCard.genTempCard(tempKey, { chat_id: chatId }) as string
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +110,7 @@ const manageHelpMsg = ({
|
|||||||
*/
|
*/
|
||||||
const manageCMDMsg = (ctx: Context.Data) => {
|
const manageCMDMsg = (ctx: Context.Data) => {
|
||||||
const {
|
const {
|
||||||
|
app,
|
||||||
body,
|
body,
|
||||||
logger,
|
logger,
|
||||||
larkService,
|
larkService,
|
||||||
@ -123,44 +124,61 @@ const manageCMDMsg = (ctx: Context.Data) => {
|
|||||||
manageIdMsg(ctx)
|
manageIdMsg(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 帮助
|
|
||||||
if (msgText.trim() === "/help") {
|
|
||||||
logger.info(`bot command is /help, chatId: ${chatId}`)
|
|
||||||
manageHelpMsg(ctx)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// CI监控
|
|
||||||
if (msgText.trim() === "/ci") {
|
|
||||||
logger.info(`bot command is /ci, chatId: ${chatId}`)
|
|
||||||
attachService.ciMonitor(chatId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 简报
|
|
||||||
if (msgText.includes("share") && msgText.includes("简报")) {
|
|
||||||
logger.info(`bot command is share report, chatId: ${chatId}`)
|
|
||||||
// 这个用时比较久,先发一条提醒用户收到了请求
|
|
||||||
// TODO: 迁移到简报服务中
|
|
||||||
larkService.message.send(
|
|
||||||
"chat_id",
|
|
||||||
chatId,
|
|
||||||
"text",
|
|
||||||
"正在为您收集简报,请稍等片刻~"
|
|
||||||
)
|
|
||||||
attachService.reportCollector(body)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 创建Sheet DB
|
|
||||||
if (msgText.trim() === "/gen db") {
|
|
||||||
logger.info(`bot command is /gen db, chatId: ${chatId}`)
|
|
||||||
createKVTemp.createFromEvent(ctx)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 选择群组信息
|
// 选择群组信息
|
||||||
if (msgText.trim().startsWith("/groupchat")) {
|
if (msgText.trim().startsWith("/g")) {
|
||||||
logger.info(`bot command is /groupchat, chatId: ${chatId}`)
|
logger.info(`bot command is /groupchat, chatId: ${chatId}`)
|
||||||
groupAgent(ctx)
|
groupAgent(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// michat专属功能
|
||||||
|
if (app === "michat") {
|
||||||
|
// 帮助
|
||||||
|
if (msgText.trim() === "/help") {
|
||||||
|
logger.info(`bot command is /help, chatId: ${chatId}`)
|
||||||
|
manageHelpMsg(ctx, "miChatGuide")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 小煎蛋专属功能
|
||||||
|
if (app === "egg") {
|
||||||
|
// CI监控
|
||||||
|
if (msgText.trim() === "/ci") {
|
||||||
|
logger.info(`bot command is /ci, chatId: ${chatId}`)
|
||||||
|
attachService.ciMonitor(chatId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 简报
|
||||||
|
if (msgText.includes("share") && msgText.includes("简报")) {
|
||||||
|
logger.info(`bot command is share report, chatId: ${chatId}`)
|
||||||
|
// 这个用时比较久,先发一条提醒用户收到了请求
|
||||||
|
// TODO: 迁移到简报服务中
|
||||||
|
larkService.message.send(
|
||||||
|
"chat_id",
|
||||||
|
chatId,
|
||||||
|
"text",
|
||||||
|
"正在为您收集简报,请稍等片刻~"
|
||||||
|
)
|
||||||
|
attachService.reportCollector(body)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 创建Sheet DB
|
||||||
|
if (msgText.trim() === "/gen db") {
|
||||||
|
logger.info(`bot command is /gen db, chatId: ${chatId}`)
|
||||||
|
createKVTemp.createFromEvent(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 帮助
|
||||||
|
if (msgText.trim() === "/help") {
|
||||||
|
logger.info(`bot command is /help, chatId: ${chatId}`)
|
||||||
|
manageHelpMsg(ctx, "eggGuide")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,48 @@
|
|||||||
import { LarkService } from "../../services"
|
// import logger from "@egg/logger"
|
||||||
|
|
||||||
const service = new LarkService("egg", "")
|
// import getChatHistory from "../../routes/bot/groupAgent/chatHistory"
|
||||||
|
// import { LarkService } from "../../services"
|
||||||
|
|
||||||
const currentTime = Math.floor(new Date().getTime() / 1000)
|
// const service = new LarkService("michat", "")
|
||||||
const yesterdayTime = currentTime - 24 * 60 * 60
|
|
||||||
|
|
||||||
const res = await service.message.getHistory(
|
// const currentTime = Math.floor(new Date().getTime() / 1000)
|
||||||
"oc_c83f627bde3da39b01bbbfb026a00111",
|
// const weekAgoTime = currentTime - 7 * 24 * 60 * 60
|
||||||
yesterdayTime.toString(),
|
|
||||||
currentTime.toString()
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(JSON.stringify(res, null, 2))
|
// const res = await service.message.getHistory(
|
||||||
|
// "oc_bd23da1ae9948654fc04365d7d102d73",
|
||||||
|
// weekAgoTime.toString(),
|
||||||
|
// currentTime.toString()
|
||||||
|
// )
|
||||||
|
|
||||||
|
// // const res = await getChatHistory(
|
||||||
|
// // { larkService: service, logger: logger },
|
||||||
|
// // {
|
||||||
|
// // chatId: "oc_bd23da1ae9948654fc04365d7d102d73",
|
||||||
|
// // timeScope: "",
|
||||||
|
// // startTime: "2024-10-16 00:00:00",
|
||||||
|
// // endTime: "2024-10-24 00:00:00",
|
||||||
|
// // mentions: [],
|
||||||
|
// // }
|
||||||
|
// // )
|
||||||
|
// // {
|
||||||
|
// // "user": "左建光",
|
||||||
|
// // "content": "Anthropic经过一番操作已经是和openai并肩的AI双雄了[呲牙]",
|
||||||
|
// // "time": "2024/10/23 09:25:33"
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // "user": "魏柏楠",
|
||||||
|
// // "content": "@Mi Chat /id",
|
||||||
|
// // "time": "2024/10/23 10:02:42"
|
||||||
|
// // }
|
||||||
|
// console.log(JSON.stringify(res, null, 2))
|
||||||
|
|
||||||
|
// // 把res内容输出到csv文件,保留user、content、time字段,使用逗号分隔
|
||||||
|
// // 手写代码实现
|
||||||
|
// const fileContent = res
|
||||||
|
// .filter(({ user, content, time }) => user && content && time)
|
||||||
|
// .map(
|
||||||
|
// ({ user, content, time }) =>
|
||||||
|
// `${time},${user},${content.replace(/,/g, ",").replace(/\n/g, " ")}`
|
||||||
|
// )
|
||||||
|
// .join("\n")
|
||||||
|
// await Bun.write("output.csv", fileContent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user