@@ -274,6 +274,24 @@ export class ClientBase extends EventEmitter {
274
274
console . log ( "Twitter user ID:" , userId ) ;
275
275
this . twitterUserId = userId ;
276
276
277
+ // Initialize Twitter profile
278
+ const profile = await this . initializeProfile ( ) ;
279
+ if ( profile ) {
280
+ console . log ( "Twitter profile initialized:" , profile ) ;
281
+
282
+ // Store profile info for use in responses
283
+ this . runtime . character = {
284
+ ...this . runtime . character ,
285
+ twitterProfile : {
286
+ username : profile . username ,
287
+ screenName : profile . screenName ,
288
+ bio : profile . bio ,
289
+ nicknames : profile . nicknames
290
+ }
291
+ } ;
292
+ }
293
+
294
+
277
295
await this . populateTimeline ( ) ;
278
296
279
297
this . onReady ( ) ;
@@ -603,4 +621,34 @@ export class ClientBase extends EventEmitter {
603
621
} ) ;
604
622
}
605
623
}
624
+
625
+ async initializeProfile ( ) {
626
+ const username = this . runtime . getSetting ( "TWITTER_USERNAME" ) ;
627
+ if ( ! username ) {
628
+ console . error ( "Twitter username not configured" ) ;
629
+ return ;
630
+ }
631
+
632
+ try {
633
+ const profile = await this . requestQueue . add ( async ( ) => {
634
+ const profile = await this . twitterClient . getProfile ( username ) ;
635
+ return {
636
+ username,
637
+ screenName : profile . name || this . runtime . character . name ,
638
+ bio : profile . biography || typeof this . runtime . character . bio === 'string' ? this . runtime . character . bio as string : this . runtime . character . bio . length > 0 ? this . runtime . character . bio [ 0 ] : "" ,
639
+ nicknames : this . runtime . character . twitterProfile ?. nicknames || [ ]
640
+ } ;
641
+ } ) ;
642
+
643
+ return profile ;
644
+ } catch ( error ) {
645
+ console . error ( "Error fetching Twitter profile:" , error ) ;
646
+ return {
647
+ username : this . runtime . character . name ,
648
+ screenName : username ,
649
+ bio : typeof this . runtime . character . bio === 'string' ? this . runtime . character . bio as string : this . runtime . character . bio . length > 0 ? this . runtime . character . bio [ 0 ] : "" ,
650
+ nicknames : this . runtime . character . twitterProfile ?. nicknames || [ ]
651
+ } ;
652
+ }
653
+ }
606
654
}
0 commit comments