File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ TWITTER_USERNAME= # Account username
70
70
TWITTER_PASSWORD = # Account password
71
71
TWITTER_EMAIL = # Account email
72
72
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
+
73
79
TWITTER_POLL_INTERVAL = 120 # How often (in seconds) the bot should check for interactions
74
80
TWITTER_SEARCH_ENABLE = FALSE # Enable timeline search, WARNING this greatly increases your chance of getting banned
75
81
TWITTER_TARGET_USERS = # Comma separated list of Twitter user names to interact with
Original file line number Diff line number Diff line change @@ -261,7 +261,20 @@ export class ClientBase extends EventEmitter {
261
261
throw new Error ( "Twitter username not configured" ) ;
262
262
}
263
263
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 ) ;
265
278
266
279
if ( cachedCookies ) {
267
280
elizaLogger . info ( "Using cached cookies" ) ;
You can’t perform that action at this time.
0 commit comments