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

fix: Twitter login notifications, incorrect cookie management. #1330

Merged
merged 5 commits into from
Dec 23, 2024
Merged
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
21 changes: 12 additions & 9 deletions packages/client-twitter/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,25 @@ export class ClientBase extends EventEmitter {
elizaLogger.log("Waiting for Twitter login");
while (retries > 0) {
try {
await this.twitterClient.login(
username,
password,
email,
twitter2faSecret
);
if (await this.twitterClient.isLoggedIn()) {
if (await this.twitterClient.isLoggedIn()) { // cookies are valid, no login required
elizaLogger.info("Successfully logged in.");
if (!cachedCookies) {
break;
} else {
await this.twitterClient.login(
username,
password,
email,
twitter2faSecret
);
if (await this.twitterClient.isLoggedIn()) { // fresh login, store new cookies
elizaLogger.info("Successfully logged in.");
elizaLogger.info("Caching cookies");
await this.cacheCookies(
username,
await this.twitterClient.getCookies()
);
break;
}
break;
}
} catch (error) {
elizaLogger.error(`Login attempt failed: ${error.message}`);
Expand Down
Loading