Skip to content

Commit

Permalink
feat: make twitter retry limit a env
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Dec 19, 2024
1 parent 81d0273 commit fe3afef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ function initializeDbCache(character: Character, db: IDatabaseCacheAdapter) {

async function startAgent(
character: Character,
directClient
directClient: DirectClient
): Promise<AgentRuntime> {
let db: IDatabaseAdapter & IDatabaseCacheAdapter;
try {
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion packages/client-twitter/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand Down

0 comments on commit fe3afef

Please sign in to comment.