inspiration-agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +368 -0
- package/dist/.env.example +53 -0
- package/dist/README.md +368 -0
- package/dist/agent/ai.agent.js +712 -0
- package/dist/channel/feishu-connection.js +238 -0
- package/dist/channel/feishu.service.js +222 -0
- package/dist/cli.js +659 -0
- package/dist/config/system.prompt.txt +312 -0
- package/dist/index.js +176 -0
- package/dist/model/base-llm.service.js +320 -0
- package/dist/model/deepseek.service.js +18 -0
- package/dist/model/kimi.service.js +19 -0
- package/dist/model/minimax.service.js +35 -0
- package/dist/model/zhipu.service.js +26 -0
- package/dist/services/database.service.js +697 -0
- package/dist/services/memory.manager.js +486 -0
- package/dist/services/message.queue.js +157 -0
- package/dist/tools/browser.tools.js +814 -0
- package/dist/tools/command.tools.js +361 -0
- package/dist/tools/file.tools.js +222 -0
- package/dist/tools/memory.tools.js +393 -0
- package/dist/tools/scheduler.tools.js +559 -0
- package/dist/tools/search.tools.js +208 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/markdown-renderer.js +207 -0
- package/package.json +51 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
const logger = require("../utils/logger");
|
|
2
|
+
const FeishuService = require("./feishu.service");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 飞书事件订阅管理器
|
|
6
|
+
* 使用事件订阅方式接收飞书消息
|
|
7
|
+
*/
|
|
8
|
+
class FeishuEventSubscription {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.feishuService = new FeishuService();
|
|
11
|
+
this.aiAgent = null;
|
|
12
|
+
this.isRunning = false;
|
|
13
|
+
this.processedMessages = new Map();
|
|
14
|
+
this.MESSAGE_TTL = 3 * 60 * 1000; // 3分钟(毫秒)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 初始化并启动事件订阅
|
|
19
|
+
* @param {AIAgent} aiAgent - AI智能体实例
|
|
20
|
+
*/
|
|
21
|
+
async init(aiAgent) {
|
|
22
|
+
this.aiAgent = aiAgent;
|
|
23
|
+
this.isRunning = true;
|
|
24
|
+
|
|
25
|
+
logger.info("正在初始化飞书事件订阅...");
|
|
26
|
+
|
|
27
|
+
this.aiAgent.setFeishuService(this.feishuService);
|
|
28
|
+
|
|
29
|
+
// 启动飞书事件订阅
|
|
30
|
+
await this.feishuService.startEventSubscription(async (content, context) => {
|
|
31
|
+
try {
|
|
32
|
+
const messageId = context.message.message_id;
|
|
33
|
+
const messageTime = parseInt(context.message.create_time, 10) || Date.now();
|
|
34
|
+
const currentTime = Date.now();
|
|
35
|
+
const chatId = context.chatId;
|
|
36
|
+
|
|
37
|
+
if (chatId && !this.aiAgent.schedulerTools.defaultChatId) {
|
|
38
|
+
this.aiAgent.schedulerTools.setDefaultChatId(chatId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 检查消息是否超过3分钟
|
|
42
|
+
const timeDiff = currentTime - messageTime;
|
|
43
|
+
if (timeDiff > this.MESSAGE_TTL && messageTime > 0) {
|
|
44
|
+
logger.info(
|
|
45
|
+
`消息已过期,跳过 (消息时间: ${new Date(messageTime).toISOString()}, 距今: ${Math.floor(timeDiff / 1000)}秒)`
|
|
46
|
+
);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 使用消息ID去重
|
|
51
|
+
if (this.processedMessages.has(messageId)) {
|
|
52
|
+
logger.info(`消息已处理,跳过: ${messageId}`);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 记录已处理的消息及其时间
|
|
57
|
+
this.processedMessages.set(messageId, currentTime);
|
|
58
|
+
|
|
59
|
+
// 清理过期的消息记录
|
|
60
|
+
this.cleanupExpiredMessages(currentTime);
|
|
61
|
+
|
|
62
|
+
// 检查是否为特殊命令
|
|
63
|
+
const trimmedContent = content.trim().toLowerCase();
|
|
64
|
+
|
|
65
|
+
if (trimmedContent === "/new") {
|
|
66
|
+
this.aiAgent.clearContext();
|
|
67
|
+
await this.feishuService.sendTextMessage(chatId, "会话上下文已清空");
|
|
68
|
+
return "会话上下文已清空";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (trimmedContent === "/tokens") {
|
|
72
|
+
const stats = await this.aiAgent.getTokenStats();
|
|
73
|
+
if (!stats) {
|
|
74
|
+
await this.feishuService.sendTextMessage(chatId, "无法获取 token 统计信息");
|
|
75
|
+
return "无法获取 token 统计信息";
|
|
76
|
+
}
|
|
77
|
+
const formatNumber = (num) => num.toLocaleString();
|
|
78
|
+
const tokenText =
|
|
79
|
+
`========== Token 使用统计 ==========\n\n` +
|
|
80
|
+
`今日消耗 (${stats.today.date}):\n` +
|
|
81
|
+
` 输入 Token: ${formatNumber(stats.today.inputTokens)}\n` +
|
|
82
|
+
` 输出 Token: ${formatNumber(stats.today.outputTokens)}\n` +
|
|
83
|
+
` 总计 Token: ${formatNumber(stats.today.totalTokens)}\n` +
|
|
84
|
+
` 请求次数: ${formatNumber(stats.today.requestCount)}\n\n` +
|
|
85
|
+
`累计消耗:\n` +
|
|
86
|
+
` 输入 Token: ${formatNumber(stats.total.totalInputTokens)}\n` +
|
|
87
|
+
` 输出 Token: ${formatNumber(stats.total.totalOutputTokens)}\n` +
|
|
88
|
+
` 总计 Token: ${formatNumber(stats.total.totalTokens)}\n` +
|
|
89
|
+
` 请求次数: ${formatNumber(stats.total.totalRequestCount)}\n` +
|
|
90
|
+
`====================================`;
|
|
91
|
+
await this.feishuService.sendTextMessage(chatId, tokenText);
|
|
92
|
+
return tokenText;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (trimmedContent === "/status") {
|
|
96
|
+
const status = await this.aiAgent.getStatus();
|
|
97
|
+
const statusText =
|
|
98
|
+
`========== 服务器状态 ==========\n` +
|
|
99
|
+
`状态: ${status.status}\n` +
|
|
100
|
+
`运行时间: ${status.uptime}\n` +
|
|
101
|
+
`启动时间: ${status.startTime}\n` +
|
|
102
|
+
`\n记忆:\n` +
|
|
103
|
+
` 短期记忆: ${status.memory.shortTermCount}/${status.memory.shortTermLimit}\n` +
|
|
104
|
+
` 长期记忆: ${status.memory.longTermCount}\n` +
|
|
105
|
+
` 归档队列: ${status.memory.archiveQueueLength}\n` +
|
|
106
|
+
`\n消息队列:\n` +
|
|
107
|
+
` 队列长度: ${status.queue.length}\n` +
|
|
108
|
+
` 处理中: ${status.queue.isProcessing ? "是" : "否"}\n` +
|
|
109
|
+
` 总接收: ${status.queue.stats.totalReceived}\n` +
|
|
110
|
+
` 总处理: ${status.queue.stats.totalProcessed}\n` +
|
|
111
|
+
` 总丢弃: ${status.queue.stats.totalDropped}\n` +
|
|
112
|
+
`\n配置:\n` +
|
|
113
|
+
` 流式输出: ${status.config.enableStream ? "启用" : "禁用"}\n` +
|
|
114
|
+
` 最大上下文 Token: ${status.config.maxContextTokens}\n` +
|
|
115
|
+
` 记忆过期天数: ${status.config.memoryExpiryDays}\n` +
|
|
116
|
+
`\n系统信息:\n` +
|
|
117
|
+
` Node.js: ${status.system.nodeVersion}\n` +
|
|
118
|
+
` 平台: ${status.system.platform}\n` +
|
|
119
|
+
` 架构: ${status.system.arch}\n` +
|
|
120
|
+
` CPU 核心数: ${status.system.cpuCores}\n` +
|
|
121
|
+
` 系统负载: ${status.system.loadAverage}\n` +
|
|
122
|
+
` 总内存: ${status.system.totalMemory}\n` +
|
|
123
|
+
` 已用内存: ${status.system.usedMemory} (${status.system.memoryUsagePercent}%)\n` +
|
|
124
|
+
` 空闲内存: ${status.system.freeMemory}\n` +
|
|
125
|
+
`\n进程信息:\n` +
|
|
126
|
+
` PID: ${status.process.pid}\n` +
|
|
127
|
+
` 内存占用 (RSS): ${status.process.memoryRSS}\n` +
|
|
128
|
+
` 堆内存: ${status.process.memoryHeapUsed} / ${status.process.memoryHeapTotal} (${status.process.heapUsagePercent}%)\n` +
|
|
129
|
+
` 外部内存: ${status.process.memoryExternal}\n` +
|
|
130
|
+
` CPU 用户态: ${status.process.cpuUser}ms\n` +
|
|
131
|
+
` CPU 内核态: ${status.process.cpuSystem}ms\n` +
|
|
132
|
+
`===============================`;
|
|
133
|
+
await this.feishuService.sendTextMessage(chatId, statusText);
|
|
134
|
+
return statusText;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (trimmedContent === "/shutdown") {
|
|
138
|
+
await this.feishuService.sendTextMessage(chatId, "服务正在停止...");
|
|
139
|
+
await this.aiAgent.shutdown();
|
|
140
|
+
return "服务正在停止...";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
logger.info(`处理飞书消息: ${content}`);
|
|
144
|
+
|
|
145
|
+
const queueStatus = this.aiAgent.getQueueStatus();
|
|
146
|
+
if (queueStatus.queueLength > 0 || queueStatus.isProcessing) {
|
|
147
|
+
logger.info(
|
|
148
|
+
`消息已加入队列 (当前队列长度: ${queueStatus.queueLength}, 处理中: ${queueStatus.isProcessing})`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let responseResult = null;
|
|
153
|
+
|
|
154
|
+
const enqueued = this.aiAgent.enqueueMessage(content, "feishu", {
|
|
155
|
+
chatId: context.chatId,
|
|
156
|
+
onComplete: async (result) => {
|
|
157
|
+
logger.info(`飞书消息处理完成,发送回复到飞书`);
|
|
158
|
+
try {
|
|
159
|
+
await this.feishuService.sendTextMessage(context.chatId, result);
|
|
160
|
+
responseResult = result;
|
|
161
|
+
logger.info(`飞书回复发送成功`);
|
|
162
|
+
} catch (sendError) {
|
|
163
|
+
logger.error(`飞书回复发送失败: ${sendError.message}`);
|
|
164
|
+
responseResult = `处理完成,但回复发送失败: ${sendError.message}`;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (!enqueued) {
|
|
170
|
+
return "系统繁忙,请稍后重试";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return new Promise((resolve) => {
|
|
174
|
+
const maxWait = 1000 * 60 * 300;
|
|
175
|
+
const startTime = Date.now();
|
|
176
|
+
|
|
177
|
+
const checkWithTimeout = async () => {
|
|
178
|
+
const status = this.aiAgent.getQueueStatus();
|
|
179
|
+
if (status.queueLength === 0 && !status.isProcessing) {
|
|
180
|
+
resolve(responseResult || "处理完成");
|
|
181
|
+
} else if (Date.now() - startTime > maxWait) {
|
|
182
|
+
resolve("处理超时,请稍后查看结果");
|
|
183
|
+
} else {
|
|
184
|
+
setTimeout(checkWithTimeout, 100);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
checkWithTimeout();
|
|
189
|
+
});
|
|
190
|
+
} catch (error) {
|
|
191
|
+
logger.error(`AI处理消息失败: ${error}`);
|
|
192
|
+
return `处理消息时发生错误: ${error.message}`;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
logger.info("飞书事件订阅已启动,正在监听消息...");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 清理过期的消息记录
|
|
201
|
+
* @param {number} currentTime - 当前时间戳
|
|
202
|
+
*/
|
|
203
|
+
cleanupExpiredMessages(currentTime) {
|
|
204
|
+
const expiredThreshold = currentTime - this.MESSAGE_TTL;
|
|
205
|
+
|
|
206
|
+
for (const [messageId, processTime] of this.processedMessages.entries()) {
|
|
207
|
+
if (processTime < expiredThreshold) {
|
|
208
|
+
this.processedMessages.delete(messageId);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 限制缓存大小,避免内存泄漏
|
|
213
|
+
if (this.processedMessages.size > 1000) {
|
|
214
|
+
const entries = Array.from(this.processedMessages.entries());
|
|
215
|
+
entries.sort((a, b) => a[1] - b[1]);
|
|
216
|
+
|
|
217
|
+
// 删除最旧的 20% 记录
|
|
218
|
+
const deleteCount = Math.floor(entries.length * 0.2);
|
|
219
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
220
|
+
this.processedMessages.delete(entries[i][0]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 停止事件订阅
|
|
227
|
+
*/
|
|
228
|
+
async stop() {
|
|
229
|
+
if (this.isRunning) {
|
|
230
|
+
this.isRunning = false;
|
|
231
|
+
this.processedMessages.clear();
|
|
232
|
+
await this.feishuService.stopEventSubscription();
|
|
233
|
+
logger.info("飞书事件订阅已停止");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
module.exports = FeishuEventSubscription;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
const lark = require("@larksuiteoapi/node-sdk");
|
|
2
|
+
const logger = require("../utils/logger");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 飞书服务类
|
|
6
|
+
* 负责与飞书开放平台 API 交互,使用长连接接收消息
|
|
7
|
+
*/
|
|
8
|
+
class FeishuService {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.wsClient = null;
|
|
11
|
+
this.eventDispatcher = null;
|
|
12
|
+
this.appId = process.env.FEISHU_APP_ID;
|
|
13
|
+
this.appSecret = process.env.FEISHU_APP_SECRET;
|
|
14
|
+
this.messageHandler = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 初始化飞书 WebSocket 客户端
|
|
19
|
+
*/
|
|
20
|
+
init() {
|
|
21
|
+
this.wsClient = new lark.WSClient({
|
|
22
|
+
appId: this.appId,
|
|
23
|
+
appSecret: this.appSecret,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
logger.info("飞书 WebSocket 客户端初始化成功");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取飞书客户端实例
|
|
31
|
+
*/
|
|
32
|
+
getClient() {
|
|
33
|
+
if (!this.wsClient) {
|
|
34
|
+
this.init();
|
|
35
|
+
}
|
|
36
|
+
return this.wsClient;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 启动事件订阅监听
|
|
41
|
+
* @param {Function} messageHandler - 消息处理函数
|
|
42
|
+
*/
|
|
43
|
+
async startEventSubscription(messageHandler) {
|
|
44
|
+
try {
|
|
45
|
+
this.messageHandler = messageHandler;
|
|
46
|
+
const wsClient = this.getClient();
|
|
47
|
+
|
|
48
|
+
// 创建事件分发器并注册消息事件处理器
|
|
49
|
+
this.eventDispatcher = new lark.EventDispatcher({}).register({
|
|
50
|
+
"im.message.receive_v1": async (data) => {
|
|
51
|
+
logger.debug(`收到飞书消息事件,数据结构: ${JSON.stringify(data, null, 2)}`);
|
|
52
|
+
await this.handleMessageEvent(data);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 启动 WebSocket 长连接
|
|
57
|
+
logger.info("正在启动飞书长连接...");
|
|
58
|
+
await wsClient.start({ eventDispatcher: this.eventDispatcher });
|
|
59
|
+
|
|
60
|
+
logger.info("飞书长连接已建立");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
logger.error(`飞书长连接启动失败: ${error}`);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 停止事件订阅
|
|
69
|
+
*/
|
|
70
|
+
async stopEventSubscription() {
|
|
71
|
+
try {
|
|
72
|
+
if (this.wsClient) {
|
|
73
|
+
await this.wsClient.stop();
|
|
74
|
+
logger.info("飞书长连接已关闭");
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
logger.error(`关闭飞书长连接失败: ${error}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 发送文本消息到飞书
|
|
83
|
+
* @param {string} chatId - 聊天ID
|
|
84
|
+
* @param {string} content - 消息内容
|
|
85
|
+
* @returns {Promise<Object>} 发送结果
|
|
86
|
+
*/
|
|
87
|
+
async sendTextMessage(chatId, content) {
|
|
88
|
+
try {
|
|
89
|
+
if (!content || typeof content !== "string") {
|
|
90
|
+
logger.error(`消息内容无效: ${typeof content}`);
|
|
91
|
+
throw new Error("消息内容无效");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const trimmedContent = content.trim();
|
|
95
|
+
if (trimmedContent.length === 0) {
|
|
96
|
+
logger.error("消息内容为空");
|
|
97
|
+
throw new Error("消息内容为空");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const client = new lark.Client({
|
|
101
|
+
appId: this.appId,
|
|
102
|
+
appSecret: this.appSecret,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const response = await client.im.message.create({
|
|
106
|
+
params: {
|
|
107
|
+
receive_id_type: "chat_id",
|
|
108
|
+
},
|
|
109
|
+
data: {
|
|
110
|
+
receive_id: chatId,
|
|
111
|
+
content: JSON.stringify({
|
|
112
|
+
text: trimmedContent,
|
|
113
|
+
}),
|
|
114
|
+
msg_type: "text",
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
logger.info(`消息发送成功: ${JSON.stringify(response.data)}`);
|
|
119
|
+
return response.data;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
logger.error(`消息发送失败: ${error.message}`);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 发送富文本消息到飞书
|
|
128
|
+
* @param {string} chatId - 聊天ID
|
|
129
|
+
* @param {string} title - 消息标题
|
|
130
|
+
* @param {string} content - 消息内容
|
|
131
|
+
* @returns {Promise<Object>} 发送结果
|
|
132
|
+
*/
|
|
133
|
+
async sendRichTextMessage(chatId, title, content) {
|
|
134
|
+
try {
|
|
135
|
+
const client = new lark.Client({
|
|
136
|
+
appId: this.appId,
|
|
137
|
+
appSecret: this.appSecret,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const response = await client.im.message.create({
|
|
141
|
+
params: {
|
|
142
|
+
receive_id_type: "chat_id",
|
|
143
|
+
},
|
|
144
|
+
data: {
|
|
145
|
+
receive_id: chatId,
|
|
146
|
+
content: JSON.stringify({
|
|
147
|
+
elements: [
|
|
148
|
+
{
|
|
149
|
+
tag: "div",
|
|
150
|
+
text: {
|
|
151
|
+
content: title,
|
|
152
|
+
tag: "lark_md",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
tag: "div",
|
|
157
|
+
text: {
|
|
158
|
+
content: content,
|
|
159
|
+
tag: "lark_md",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
header: {
|
|
164
|
+
template: "blue",
|
|
165
|
+
title: {
|
|
166
|
+
content: title,
|
|
167
|
+
tag: "plain_text",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
msg_type: "interactive",
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
logger.info(`富文本消息发送成功: ${response.data}`);
|
|
176
|
+
return response.data;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
logger.error(`富文本消息发送失败: ${error}`);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 处理飞书消息事件
|
|
185
|
+
* @param {Object} data - 事件数据
|
|
186
|
+
* @returns {Promise<Object>} 处理结果
|
|
187
|
+
*/
|
|
188
|
+
async handleMessageEvent(data) {
|
|
189
|
+
try {
|
|
190
|
+
// 兼容不同的数据结构
|
|
191
|
+
const event = data.event || data;
|
|
192
|
+
const message = event.message;
|
|
193
|
+
const chatId = message.chat_id;
|
|
194
|
+
const content = JSON.parse(message.content).text;
|
|
195
|
+
const senderId = event.sender.sender_id.user_id;
|
|
196
|
+
|
|
197
|
+
logger.info("收到飞书消息:", {
|
|
198
|
+
chatId,
|
|
199
|
+
senderId,
|
|
200
|
+
content,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (this.messageHandler) {
|
|
204
|
+
const replyContent = await this.messageHandler(content, {
|
|
205
|
+
chatId,
|
|
206
|
+
senderId,
|
|
207
|
+
message,
|
|
208
|
+
event,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return { success: true, chatId, senderId, replyContent };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return { success: true, chatId, senderId };
|
|
215
|
+
} catch (error) {
|
|
216
|
+
logger.error(`消息事件处理失败: ${error}`);
|
|
217
|
+
return { success: false, error: error.message };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
module.exports = FeishuService;
|