From fe3afef712dcdecbc86080432742aba917f8565f Mon Sep 17 00:00:00 2001 From: xiaohuo Date: Fri, 20 Dec 2024 01:51:01 +0800 Subject: [PATCH 1/2] feat: make twitter retry limit a env --- agent/src/index.ts | 8 ++++---- packages/client-twitter/src/base.ts | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/agent/src/index.ts b/agent/src/index.ts index d4f0448f63..9e6498b7f9 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -573,7 +573,7 @@ function initializeDbCache(character: Character, db: IDatabaseCacheAdapter) { async function startAgent( character: Character, - directClient + directClient: DirectClient ): Promise { let db: IDatabaseAdapter & IDatabaseCacheAdapter; try { @@ -648,9 +648,9 @@ const startAgents = async () => { } // upload some agent functionality into directClient - directClient.startAgent = async character => { - // wrap it so we don't have to inject directClient later - return startAgent(character, directClient) + directClient.startAgent = async (character: Character) => { + // wrap it so we don't have to inject directClient later + return startAgent(character, directClient); }; directClient.start(serverPort); diff --git a/packages/client-twitter/src/base.ts b/packages/client-twitter/src/base.ts index 76fe766bf1..861821170d 100644 --- a/packages/client-twitter/src/base.ts +++ b/packages/client-twitter/src/base.ts @@ -157,6 +157,10 @@ export class ClientBase extends EventEmitter { const username = this.runtime.getSetting("TWITTER_USERNAME"); const password = this.runtime.getSetting("TWITTER_PASSWORD"); const email = this.runtime.getSetting("TWITTER_EMAIL"); + let retries = parseInt( + this.runtime.getSetting("TWITTER_RETRY_LIMIT") || "5", + 10 + ); const twitter2faSecret = this.runtime.getSetting("TWITTER_2FA_SECRET") || undefined; const cookies = this.runtime.getSetting("TWITTER_COOKIES"); @@ -180,7 +184,6 @@ export class ClientBase extends EventEmitter { } elizaLogger.log("Waiting for Twitter login"); - let retries = 5; // Optional: Set a retry limit while (retries > 0) { const cookies = await this.twitterClient.getCookies(); if ((await this.twitterClient.isLoggedIn()) && !!cookies) { From 8046d2945fd9e55dfc15f4ed067987c1f41281e1 Mon Sep 17 00:00:00 2001 From: xiaohuo Date: Fri, 20 Dec 2024 01:52:57 +0800 Subject: [PATCH 2/2] chore: env update --- .env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.example b/.env.example index d2d89eda85..92836a1df0 100644 --- a/.env.example +++ b/.env.example @@ -55,6 +55,7 @@ TWITTER_COOKIES= # Account cookies TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions TWITTER_SEARCH_ENABLE=FALSE # Enable timeline search, WARNING this greatly increases your chance of getting banned TWITTER_TARGET_USERS= # Comma separated list of Twitter user names to interact with +TWITTER_RETRY_LIMIT= # Maximum retry attempts for Twitter login X_SERVER_URL= XAI_API_KEY=