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