@elizaos/plugin-discord 1.0.0-beta.36 → 1.0.0-beta.38
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/dist/index.js +72 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2217,6 +2217,9 @@ var MessageManager = class {
|
|
|
2217
2217
|
if (message.guild) {
|
|
2218
2218
|
const guild = await message.guild.fetch();
|
|
2219
2219
|
type = await this.getChannelType(message.channel);
|
|
2220
|
+
if (type === null) {
|
|
2221
|
+
logger4.warn("null channel type, discord message", message);
|
|
2222
|
+
}
|
|
2220
2223
|
serverId = guild.id;
|
|
2221
2224
|
} else {
|
|
2222
2225
|
type = ChannelType7.DM;
|
|
@@ -2250,6 +2253,20 @@ var MessageManager = class {
|
|
|
2250
2253
|
}
|
|
2251
2254
|
const entityId2 = createUniqueUuid4(this.runtime, message.author.id);
|
|
2252
2255
|
const messageId = createUniqueUuid4(this.runtime, message.id);
|
|
2256
|
+
const channel = message.channel;
|
|
2257
|
+
const startTyping = () => {
|
|
2258
|
+
try {
|
|
2259
|
+
channel.sendTyping();
|
|
2260
|
+
} catch (err) {
|
|
2261
|
+
logger4.warn("Error sending typing indicator:", err);
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
startTyping();
|
|
2265
|
+
const typingInterval = setInterval(startTyping, 8e3);
|
|
2266
|
+
const typingData = {
|
|
2267
|
+
interval: typingInterval,
|
|
2268
|
+
cleared: false
|
|
2269
|
+
};
|
|
2253
2270
|
const newMessage = {
|
|
2254
2271
|
id: messageId,
|
|
2255
2272
|
entityId: entityId2,
|
|
@@ -2264,6 +2281,10 @@ var MessageManager = class {
|
|
|
2264
2281
|
url: message.url,
|
|
2265
2282
|
inReplyTo: message.reference?.messageId ? createUniqueUuid4(this.runtime, message.reference?.messageId) : void 0
|
|
2266
2283
|
},
|
|
2284
|
+
metadata: {
|
|
2285
|
+
entityName: name,
|
|
2286
|
+
type: "message"
|
|
2287
|
+
},
|
|
2267
2288
|
createdAt: message.createdTimestamp
|
|
2268
2289
|
};
|
|
2269
2290
|
const callback = async (content, files) => {
|
|
@@ -2271,38 +2292,49 @@ var MessageManager = class {
|
|
|
2271
2292
|
if (message.id && !content.inReplyTo) {
|
|
2272
2293
|
content.inReplyTo = createUniqueUuid4(this.runtime, message.id);
|
|
2273
2294
|
}
|
|
2274
|
-
|
|
2275
|
-
message.
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2295
|
+
try {
|
|
2296
|
+
const messages = await sendMessageInChunks(channel, content.text, message.id, files);
|
|
2297
|
+
const memories = [];
|
|
2298
|
+
for (const m of messages) {
|
|
2299
|
+
const actions = content.actions;
|
|
2300
|
+
const memory = {
|
|
2301
|
+
id: createUniqueUuid4(this.runtime, m.id),
|
|
2302
|
+
entityId: this.runtime.agentId,
|
|
2303
|
+
agentId: this.runtime.agentId,
|
|
2304
|
+
content: {
|
|
2305
|
+
...content,
|
|
2306
|
+
actions,
|
|
2307
|
+
inReplyTo: messageId,
|
|
2308
|
+
url: m.url,
|
|
2309
|
+
channelType: type
|
|
2310
|
+
},
|
|
2311
|
+
roomId,
|
|
2312
|
+
createdAt: m.createdTimestamp
|
|
2313
|
+
};
|
|
2314
|
+
memories.push(memory);
|
|
2315
|
+
}
|
|
2316
|
+
for (const m of memories) {
|
|
2317
|
+
await this.runtime.createMemory(m, "messages");
|
|
2318
|
+
}
|
|
2319
|
+
if (typingData.interval && !typingData.cleared) {
|
|
2320
|
+
clearInterval(typingData.interval);
|
|
2321
|
+
typingData.cleared = true;
|
|
2322
|
+
}
|
|
2323
|
+
return memories;
|
|
2324
|
+
} catch (error) {
|
|
2325
|
+
console.error("Error sending message:", error);
|
|
2326
|
+
if (typingData.interval && !typingData.cleared) {
|
|
2327
|
+
clearInterval(typingData.interval);
|
|
2328
|
+
typingData.cleared = true;
|
|
2329
|
+
}
|
|
2330
|
+
return [];
|
|
2301
2331
|
}
|
|
2302
|
-
return memories;
|
|
2303
2332
|
} catch (error) {
|
|
2304
|
-
console.error("Error
|
|
2305
|
-
|
|
2333
|
+
console.error("Error handling message:", error);
|
|
2334
|
+
if (typingData.interval && !typingData.cleared) {
|
|
2335
|
+
clearInterval(typingData.interval);
|
|
2336
|
+
typingData.cleared = true;
|
|
2337
|
+
}
|
|
2306
2338
|
}
|
|
2307
2339
|
};
|
|
2308
2340
|
this.runtime.emitEvent(["DISCORD_MESSAGE_RECEIVED" /* MESSAGE_RECEIVED */, EventType.MESSAGE_RECEIVED], {
|
|
@@ -2310,6 +2342,12 @@ var MessageManager = class {
|
|
|
2310
2342
|
message: newMessage,
|
|
2311
2343
|
callback
|
|
2312
2344
|
});
|
|
2345
|
+
setTimeout(() => {
|
|
2346
|
+
if (typingData.interval && !typingData.cleared) {
|
|
2347
|
+
clearInterval(typingData.interval);
|
|
2348
|
+
typingData.cleared = true;
|
|
2349
|
+
}
|
|
2350
|
+
}, 500);
|
|
2313
2351
|
} catch (error) {
|
|
2314
2352
|
console.error("Error handling message:", error);
|
|
2315
2353
|
}
|
|
@@ -2359,7 +2397,8 @@ var MessageManager = class {
|
|
|
2359
2397
|
if (this.runtime.getService(ServiceType4.VIDEO)?.isVideoUrl(url)) {
|
|
2360
2398
|
const videoService = this.runtime.getService(ServiceType4.VIDEO);
|
|
2361
2399
|
if (!videoService) {
|
|
2362
|
-
|
|
2400
|
+
logger4.warn("Video service not found");
|
|
2401
|
+
continue;
|
|
2363
2402
|
}
|
|
2364
2403
|
const videoInfo = await videoService.processVideo(url, this.runtime);
|
|
2365
2404
|
attachments.push({
|
|
@@ -2373,7 +2412,8 @@ var MessageManager = class {
|
|
|
2373
2412
|
} else {
|
|
2374
2413
|
const browserService = this.runtime.getService(ServiceType4.BROWSER);
|
|
2375
2414
|
if (!browserService) {
|
|
2376
|
-
|
|
2415
|
+
logger4.warn("Browser service not found");
|
|
2416
|
+
continue;
|
|
2377
2417
|
}
|
|
2378
2418
|
const { title, description: summary } = await browserService.getPageContent(
|
|
2379
2419
|
url,
|