xiaozuoassistant 0.2.22 → 0.2.23
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.
|
@@ -57,32 +57,34 @@ export class FeishuChannel extends BaseChannel {
|
|
|
57
57
|
});
|
|
58
58
|
// Start WebSocket client
|
|
59
59
|
console.log(`Starting WebSocket client for Feishu Bot: ${name}`);
|
|
60
|
+
// MUST capture botName and client references within this loop closure to prevent overriding
|
|
61
|
+
const botName = name;
|
|
60
62
|
await wsClient.start({
|
|
61
63
|
eventDispatcher: new lark.EventDispatcher({}).register({
|
|
62
64
|
'im.message.receive_v1': async (data) => {
|
|
63
|
-
console.log(`[Feishu-${
|
|
65
|
+
console.log(`[Feishu-${botName}] Received message event:`, data);
|
|
64
66
|
const event = data.message;
|
|
65
67
|
const sender = data.sender;
|
|
66
68
|
if (!event || !sender) {
|
|
67
|
-
console.log(`[Feishu-${
|
|
69
|
+
console.log(`[Feishu-${botName}] Invalid event structure:`, data);
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
// Ignore bot messages
|
|
71
73
|
if (sender.sender_type !== 'user') {
|
|
72
|
-
console.log(`[Feishu-${
|
|
74
|
+
console.log(`[Feishu-${botName}] Ignoring bot message`);
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
75
77
|
try {
|
|
76
78
|
const content = JSON.parse(event.content).text;
|
|
77
|
-
console.log(`[Feishu-${
|
|
79
|
+
console.log(`[Feishu-${botName}] Received message: ${content}`);
|
|
78
80
|
// Use chat_id for group chats, open_id/user_id for p2p?
|
|
79
81
|
// Actually message.chat_id is universal for where the message comes from.
|
|
80
|
-
const sessionId = `feishu:${
|
|
81
|
-
console.log(`[Feishu-${
|
|
82
|
+
const sessionId = `feishu:${botName}:${event.chat_id}`;
|
|
83
|
+
console.log(`[Feishu-${botName}] Emitting message with sessionId: ${sessionId}`);
|
|
82
84
|
this.emitMessage(sessionId, content);
|
|
83
85
|
}
|
|
84
86
|
catch (e) {
|
|
85
|
-
console.error(`[Feishu-${
|
|
87
|
+
console.error(`[Feishu-${botName}] Failed to parse message content:`, e);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
})
|