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

feat: make twitter client polling configurable #683

Merged
merged 1 commit into from
Nov 30, 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ TWITTER_PASSWORD= # Account password
TWITTER_EMAIL= # Account email
TWITTER_2FA_SECRET=
TWITTER_COOKIES= # Account cookies
TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions
X_SERVER_URL=
XAI_API_KEY=
XAI_MODEL=
Expand Down
2 changes: 1 addition & 1 deletion packages/client-twitter/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class ClientBase extends EventEmitter {
username,
this.runtime.getSetting("TWITTER_PASSWORD"),
this.runtime.getSetting("TWITTER_EMAIL"),
this.runtime.getSetting("TWITTER_2FA_SECRET")
this.runtime.getSetting("TWITTER_2FA_SECRET") || undefined
twilwa marked this conversation as resolved.
Show resolved Hide resolved
);

if (await this.twitterClient.isLoggedIn()) {
Expand Down
6 changes: 4 additions & 2 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ export class TwitterInteractionClient {
this.handleTwitterInteractions();
setTimeout(
handleTwitterInteractionsLoop,
(Math.floor(Math.random() * (5 - 2 + 1)) + 2) * 60 * 1000
); // Random interval between 2-5 minutes
Number(
this.runtime.getSetting("TWITTER_POLL_INTERVAL") || 120
) * 1000 // Default to 2 minutes
);
};
handleTwitterInteractionsLoop();
}
Expand Down
Loading