Skip to content

Commit 7d6951a

Browse files
authored
Merge pull request #3053 from elizaOS/tcm-telegram-duplicated-id
fix: Message id collision in Telegram Client
2 parents d2b0639 + 3180f05 commit 7d6951a

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

packages/client-telegram/src/messageManager.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,9 @@ export class MessageManager {
195195

196196
// Check if we should post
197197
if (
198-
timeSinceLastMessage >
199-
this.autoPostConfig.inactivityThreshold ||
200-
(randomThreshold &&
201-
timeSinceLastAutoPost >
202-
(this.autoPostConfig.minTimeBetweenPosts || 0))
198+
timeSinceLastMessage > randomThreshold &&
199+
timeSinceLastAutoPost >
200+
(this.autoPostConfig.minTimeBetweenPosts || 0)
203201
) {
204202
try {
205203
const roomId = stringToUuid(
@@ -258,7 +256,7 @@ export class MessageManager {
258256
// Create and store memories
259257
const memories = messages.map((m) => ({
260258
id: stringToUuid(
261-
m.message_id.toString() + "-" + this.runtime.agentId
259+
roomId + "-" + m.message_id.toString()
262260
),
263261
userId: this.runtime.agentId,
264262
agentId: this.runtime.agentId,
@@ -384,9 +382,7 @@ export class MessageManager {
384382
);
385383

386384
const memories = messages.map((m) => ({
387-
id: stringToUuid(
388-
m.message_id.toString() + "-" + this.runtime.agentId
389-
),
385+
id: stringToUuid(roomId + "-" + m.message_id.toString()),
390386
userId: this.runtime.agentId,
391387
agentId: this.runtime.agentId,
392388
content: {
@@ -1264,7 +1260,7 @@ export class MessageManager {
12641260

12651261
// Get message ID
12661262
const messageId = stringToUuid(
1267-
message.message_id.toString() + "-" + this.runtime.agentId
1263+
roomId + "-" + message.message_id.toString()
12681264
) as UUID;
12691265

12701266
// Handle images
@@ -1339,9 +1335,7 @@ export class MessageManager {
13391335

13401336
const memory: Memory = {
13411337
id: stringToUuid(
1342-
sentMessage.message_id.toString() +
1343-
"-" +
1344-
this.runtime.agentId
1338+
roomId + "-" + sentMessage.message_id.toString()
13451339
),
13461340
agentId,
13471341
userId: agentId,

0 commit comments

Comments
 (0)