Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use BigInt for tweet IDs in client-twitter #552

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/client-twitter/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ClientBase extends EventEmitter {
twitterClient: Scraper;
runtime: IAgentRuntime;
directions: string;
lastCheckedTweetId: number | null = null;
lastCheckedTweetId: bigint | null = null;
imageDescriptionService: IImageDescriptionService;
temperature: number = 0.5;

Expand Down Expand Up @@ -588,20 +588,20 @@ export class ClientBase extends EventEmitter {

async loadLatestCheckedTweetId(): Promise<void> {
const latestCheckedTweetId =
await this.runtime.cacheManager.get<number>(
await this.runtime.cacheManager.get<string>(
`twitter/${this.profile.username}/latest_checked_tweet_id`
);

if (latestCheckedTweetId) {
this.lastCheckedTweetId = latestCheckedTweetId;
this.lastCheckedTweetId = BigInt(latestCheckedTweetId);
}
}

async cacheLatestCheckedTweetId() {
if (this.lastCheckedTweetId) {
await this.runtime.cacheManager.set(
`twitter/${this.profile.username}/latest_checked_tweet_id`,
this.lastCheckedTweetId
this.lastCheckedTweetId.toString()
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class TwitterInteractionClient {
for (const tweet of uniqueTweetCandidates) {
if (
!this.client.lastCheckedTweetId ||
parseInt(tweet.id) > this.client.lastCheckedTweetId
BigInt(tweet.id) > this.client.lastCheckedTweetId
) {
elizaLogger.log("New Tweet found", tweet.permanentUrl);

Expand Down Expand Up @@ -167,7 +167,7 @@ export class TwitterInteractionClient {
});

// Update the last checked tweet ID after processing each tweet
this.client.lastCheckedTweetId = parseInt(tweet.id);
this.client.lastCheckedTweetId = BigInt(tweet.id);
}
}

Expand Down
Loading