@elizaos/plugin-twitter 1.2.16 → 1.2.17
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 +28 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6282,6 +6282,25 @@ function getRandomInterval(runtime, type) {
|
|
|
6282
6282
|
return fallbackInterval;
|
|
6283
6283
|
}
|
|
6284
6284
|
|
|
6285
|
+
// src/utils/time.ts
|
|
6286
|
+
function getEpochMs(ts) {
|
|
6287
|
+
if (!ts) return Date.now();
|
|
6288
|
+
const digits = Math.floor(Math.log10(ts)) + 1;
|
|
6289
|
+
if (digits <= 12) {
|
|
6290
|
+
return ts * 1e3;
|
|
6291
|
+
}
|
|
6292
|
+
if (digits === 13) {
|
|
6293
|
+
return ts;
|
|
6294
|
+
}
|
|
6295
|
+
if (digits === 16) {
|
|
6296
|
+
return Math.floor(ts / 1e3);
|
|
6297
|
+
}
|
|
6298
|
+
while (ts > 9999999999999) {
|
|
6299
|
+
ts = Math.floor(ts / 1e3);
|
|
6300
|
+
}
|
|
6301
|
+
return ts;
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6285
6304
|
// src/interactions.ts
|
|
6286
6305
|
var TwitterInteractionClient = class {
|
|
6287
6306
|
/**
|
|
@@ -6435,7 +6454,7 @@ var TwitterInteractionClient = class {
|
|
|
6435
6454
|
if (existingMemory) {
|
|
6436
6455
|
continue;
|
|
6437
6456
|
}
|
|
6438
|
-
const tweetAge = Date.now() - tweet.timestamp
|
|
6457
|
+
const tweetAge = Date.now() - getEpochMs(tweet.timestamp);
|
|
6439
6458
|
const maxAge = 24 * 60 * 60 * 1e3;
|
|
6440
6459
|
if (tweetAge > maxAge) {
|
|
6441
6460
|
continue;
|
|
@@ -6464,7 +6483,7 @@ var TwitterInteractionClient = class {
|
|
|
6464
6483
|
1 /* Latest */
|
|
6465
6484
|
);
|
|
6466
6485
|
const relevantTweets = searchResult.tweets.filter((tweet) => {
|
|
6467
|
-
const tweetAge = Date.now() - tweet.timestamp
|
|
6486
|
+
const tweetAge = Date.now() - getEpochMs(tweet.timestamp);
|
|
6468
6487
|
return tweetAge < 12 * 60 * 60 * 1e3;
|
|
6469
6488
|
});
|
|
6470
6489
|
if (relevantTweets.length > 0) {
|
|
@@ -6583,7 +6602,7 @@ Response (YES/NO):`;
|
|
|
6583
6602
|
},
|
|
6584
6603
|
agentId: this.runtime.agentId,
|
|
6585
6604
|
roomId,
|
|
6586
|
-
createdAt: tweet.timestamp
|
|
6605
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
6587
6606
|
};
|
|
6588
6607
|
await this.runtime.createMemory(tweetMemory, "messages");
|
|
6589
6608
|
}
|
|
@@ -6602,7 +6621,7 @@ Response (YES/NO):`;
|
|
|
6602
6621
|
},
|
|
6603
6622
|
agentId: this.runtime.agentId,
|
|
6604
6623
|
roomId: createUniqueUuid2(this.runtime, tweet.conversationId),
|
|
6605
|
-
createdAt: tweet.timestamp
|
|
6624
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
6606
6625
|
};
|
|
6607
6626
|
const result = await this.handleTweet({
|
|
6608
6627
|
tweet,
|
|
@@ -6739,7 +6758,7 @@ Response (YES/NO):`;
|
|
|
6739
6758
|
},
|
|
6740
6759
|
agentId: this.runtime.agentId,
|
|
6741
6760
|
roomId,
|
|
6742
|
-
createdAt: tweet.timestamp
|
|
6761
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
6743
6762
|
};
|
|
6744
6763
|
logger4.log("Saving tweet memory...");
|
|
6745
6764
|
await this.runtime.createMemory(memory, "messages");
|
|
@@ -7428,7 +7447,7 @@ var TwitterTimelineClient = class {
|
|
|
7428
7447
|
},
|
|
7429
7448
|
entityId: createUniqueUuid4(runtime, tweet.userId),
|
|
7430
7449
|
roomId: createUniqueUuid4(runtime, tweet.conversationId),
|
|
7431
|
-
createdAt: tweet.timestamp
|
|
7450
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
7432
7451
|
};
|
|
7433
7452
|
}
|
|
7434
7453
|
async handleTimeline() {
|
|
@@ -7545,7 +7564,7 @@ ${actionSummary.join("\n")}`);
|
|
|
7545
7564
|
},
|
|
7546
7565
|
agentId: this.runtime.agentId,
|
|
7547
7566
|
roomId,
|
|
7548
|
-
createdAt: tweet.timestamp
|
|
7567
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
7549
7568
|
},
|
|
7550
7569
|
"messages"
|
|
7551
7570
|
);
|
|
@@ -8713,7 +8732,7 @@ var _ClientBase = class _ClientBase {
|
|
|
8713
8732
|
content,
|
|
8714
8733
|
agentId: this.runtime.agentId,
|
|
8715
8734
|
roomId,
|
|
8716
|
-
createdAt: tweet.timestamp
|
|
8735
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
8717
8736
|
},
|
|
8718
8737
|
"messages"
|
|
8719
8738
|
);
|
|
@@ -8794,7 +8813,7 @@ var _ClientBase = class _ClientBase {
|
|
|
8794
8813
|
content,
|
|
8795
8814
|
agentId: this.runtime.agentId,
|
|
8796
8815
|
roomId,
|
|
8797
|
-
createdAt: tweet.timestamp
|
|
8816
|
+
createdAt: getEpochMs(tweet.timestamp)
|
|
8798
8817
|
},
|
|
8799
8818
|
"messages"
|
|
8800
8819
|
);
|