Skip to content

Commit a66794a

Browse files
authored
Merge pull request #683 from cygaar/make_tweet_interval_configurable
feat: make twitter client polling configurable
2 parents 695ca0a + 68cffa3 commit a66794a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ TWITTER_PASSWORD= # Account password
3434
TWITTER_EMAIL= # Account email
3535
TWITTER_2FA_SECRET=
3636
TWITTER_COOKIES= # Account cookies
37+
TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions
3738
X_SERVER_URL=
3839
XAI_API_KEY=
3940
XAI_MODEL=

packages/client-twitter/src/base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class ClientBase extends EventEmitter {
178178
username,
179179
this.runtime.getSetting("TWITTER_PASSWORD"),
180180
this.runtime.getSetting("TWITTER_EMAIL"),
181-
this.runtime.getSetting("TWITTER_2FA_SECRET")
181+
this.runtime.getSetting("TWITTER_2FA_SECRET") || undefined
182182
);
183183

184184
if (await this.twitterClient.isLoggedIn()) {

packages/client-twitter/src/interactions.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ export class TwitterInteractionClient {
9696
this.handleTwitterInteractions();
9797
setTimeout(
9898
handleTwitterInteractionsLoop,
99-
(Math.floor(Math.random() * (5 - 2 + 1)) + 2) * 60 * 1000
100-
); // Random interval between 2-5 minutes
99+
Number(
100+
this.runtime.getSetting("TWITTER_POLL_INTERVAL") || 120
101+
) * 1000 // Default to 2 minutes
102+
);
101103
};
102104
handleTwitterInteractionsLoop();
103105
}

0 commit comments

Comments
 (0)