Skip to content

Commit 1f4b6d4

Browse files
authored
Merge pull request elizaOS#3278 from elizaOS/tcm-fix-DenyLoginSubtask
fix: DenyLoginSubtask
2 parents b6929e9 + 4b40ef5 commit 1f4b6d4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ TWITTER_USERNAME= # Account username
7070
TWITTER_PASSWORD= # Account password
7171
TWITTER_EMAIL= # Account email
7272
TWITTER_2FA_SECRET=
73+
74+
# Authentication cookies for Twitter session (this is for login using cookies and is optional)
75+
TWITTER_COOKIES_AUTH_TOKEN=
76+
TWITTER_COOKIES_CT0=
77+
TWITTER_COOKIES_GUEST_ID=
78+
7379
TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions
7480
TWITTER_SEARCH_ENABLE=FALSE # Enable timeline search, WARNING this greatly increases your chance of getting banned
7581
TWITTER_TARGET_USERS= # Comma separated list of Twitter user names to interact with

packages/client-twitter/src/base.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,20 @@ export class ClientBase extends EventEmitter {
261261
throw new Error("Twitter username not configured");
262262
}
263263

264-
const cachedCookies = await this.getCachedCookies(username);
264+
const authToken = this.runtime.getSetting("TWITTER_COOKIES_AUTH_TOKEN");
265+
const ct0 = this.runtime.getSetting("TWITTER_COOKIES_CT0");
266+
const guestId = this.runtime.getSetting("TWITTER_COOKIES_GUEST_ID");
267+
268+
const createTwitterCookies = (authToken: string, ct0: string, guestId: string) =>
269+
authToken && ct0 && guestId
270+
? [
271+
{ key: 'auth_token', value: authToken, domain: '.twitter.com' },
272+
{ key: 'ct0', value: ct0, domain: '.twitter.com' },
273+
{ key: 'guest_id', value: guestId, domain: '.twitter.com' },
274+
]
275+
: null;
276+
277+
const cachedCookies = await this.getCachedCookies(username) || createTwitterCookies(authToken, ct0, guestId);
265278

266279
if (cachedCookies) {
267280
elizaLogger.info("Using cached cookies");

0 commit comments

Comments
 (0)