orchestrix-yuri 4.0.4 → 4.0.6
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/lib/gateway/channels/feishu.js +12 -27
- package/package.json +1 -1
|
@@ -38,11 +38,14 @@ class FeishuAdapter {
|
|
|
38
38
|
|
|
39
39
|
// WebSocket long connection (no public IP needed)
|
|
40
40
|
log.feishu('Connecting via WebSocket...');
|
|
41
|
-
this.wsClient = new lark.WSClient(
|
|
42
|
-
|
|
41
|
+
this.wsClient = new lark.WSClient({
|
|
42
|
+
appId: this.appId,
|
|
43
|
+
appSecret: this.appSecret,
|
|
44
|
+
domain: lark.Domain.Feishu,
|
|
45
|
+
loggerLevel: lark.LoggerLevel.WARN,
|
|
43
46
|
});
|
|
44
47
|
|
|
45
|
-
await this.wsClient.start();
|
|
48
|
+
await this.wsClient.start({ eventDispatcher: dispatcher });
|
|
46
49
|
log.feishu('Connected via WebSocket');
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -95,21 +98,13 @@ class FeishuAdapter {
|
|
|
95
98
|
const reply = await this.onMessage(msg);
|
|
96
99
|
|
|
97
100
|
if (reply && reply.text) {
|
|
98
|
-
|
|
101
|
+
// Feishu does NOT support editing text messages (only cards).
|
|
102
|
+
// Always delete placeholder and send reply as new message.
|
|
103
|
+
if (placeholder) await this._deleteMessage(placeholder.messageId).catch(() => {});
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await this.
|
|
103
|
-
// Edit failed — delete placeholder and send new
|
|
104
|
-
await this._deleteMessage(placeholder.messageId).catch(() => {});
|
|
105
|
-
await this._sendMessage(msg.chatId, chunks[0]).catch(() => {});
|
|
106
|
-
});
|
|
107
|
-
} else {
|
|
108
|
-
// Multi-chunk: delete placeholder, send chunks
|
|
109
|
-
if (placeholder) await this._deleteMessage(placeholder.messageId).catch(() => {});
|
|
110
|
-
for (const chunk of chunks) {
|
|
111
|
-
await this._sendMessage(msg.chatId, chunk).catch(() => {});
|
|
112
|
-
}
|
|
105
|
+
const chunks = splitMessage(reply.text, 4000);
|
|
106
|
+
for (const chunk of chunks) {
|
|
107
|
+
await this._sendMessage(msg.chatId, chunk).catch(() => {});
|
|
113
108
|
}
|
|
114
109
|
} else if (placeholder) {
|
|
115
110
|
await this._deleteMessage(placeholder.messageId).catch(() => {});
|
|
@@ -146,16 +141,6 @@ class FeishuAdapter {
|
|
|
146
141
|
return { messageId: msgId ? String(msgId) : null };
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
async _editMessage(messageId, text) {
|
|
150
|
-
await this.client.im.message.patch({
|
|
151
|
-
path: { message_id: messageId },
|
|
152
|
-
data: {
|
|
153
|
-
msg_type: 'text',
|
|
154
|
-
content: JSON.stringify({ text }),
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
144
|
async _deleteMessage(messageId) {
|
|
160
145
|
await this.client.im.message.delete({
|
|
161
146
|
path: { message_id: messageId },
|