Skip to content

Commit

Permalink
Merge pull request elizaOS#683 from cygaar/make_tweet_interval_config…
Browse files Browse the repository at this point in the history
…urable

feat: make twitter client polling configurable
  • Loading branch information
twilwa authored Nov 30, 2024
2 parents 695ca0a + 68cffa3 commit a66794a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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
);

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

0 comments on commit a66794a

Please sign in to comment.