Skip to content

Commit 5507d36

Browse files
Merge pull request #552 from wraitii/bigint-for-tweet-ids
fix: Use BigInt for tweet IDs in client-twitter
2 parents a9d8417 + 23bd87e commit 5507d36

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/client-twitter/src/base.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class ClientBase extends EventEmitter {
8686
twitterClient: Scraper;
8787
runtime: IAgentRuntime;
8888
directions: string;
89-
lastCheckedTweetId: number | null = null;
89+
lastCheckedTweetId: bigint | null = null;
9090
imageDescriptionService: IImageDescriptionService;
9191
temperature: number = 0.5;
9292

@@ -588,20 +588,20 @@ export class ClientBase extends EventEmitter {
588588

589589
async loadLatestCheckedTweetId(): Promise<void> {
590590
const latestCheckedTweetId =
591-
await this.runtime.cacheManager.get<number>(
591+
await this.runtime.cacheManager.get<string>(
592592
`twitter/${this.profile.username}/latest_checked_tweet_id`
593593
);
594594

595595
if (latestCheckedTweetId) {
596-
this.lastCheckedTweetId = latestCheckedTweetId;
596+
this.lastCheckedTweetId = BigInt(latestCheckedTweetId);
597597
}
598598
}
599599

600600
async cacheLatestCheckedTweetId() {
601601
if (this.lastCheckedTweetId) {
602602
await this.runtime.cacheManager.set(
603603
`twitter/${this.profile.username}/latest_checked_tweet_id`,
604-
this.lastCheckedTweetId
604+
this.lastCheckedTweetId.toString()
605605
);
606606
}
607607
}

packages/client-twitter/src/interactions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class TwitterInteractionClient {
127127
for (const tweet of uniqueTweetCandidates) {
128128
if (
129129
!this.client.lastCheckedTweetId ||
130-
parseInt(tweet.id) > this.client.lastCheckedTweetId
130+
BigInt(tweet.id) > this.client.lastCheckedTweetId
131131
) {
132132
elizaLogger.log("New Tweet found", tweet.permanentUrl);
133133

@@ -167,7 +167,7 @@ export class TwitterInteractionClient {
167167
});
168168

169169
// Update the last checked tweet ID after processing each tweet
170-
this.client.lastCheckedTweetId = parseInt(tweet.id);
170+
this.client.lastCheckedTweetId = BigInt(tweet.id);
171171
}
172172
}
173173

0 commit comments

Comments
 (0)