@@ -96,6 +96,7 @@ function truncateToCompleteSentence(
96
96
export class TwitterPostClient {
97
97
client : ClientBase ;
98
98
runtime : IAgentRuntime ;
99
+ twitterUsername : string ;
99
100
private isProcessing : boolean = false ;
100
101
private lastProcessTime : number = 0 ;
101
102
private stopProcessingActions : boolean = false ;
@@ -111,7 +112,7 @@ export class TwitterPostClient {
111
112
timestamp : number ;
112
113
} > (
113
114
"twitter/" +
114
- this . runtime . getSetting ( "TWITTER_USERNAME" ) +
115
+ this . twitterUsername +
115
116
"/lastPost"
116
117
) ;
117
118
@@ -136,7 +137,6 @@ export class TwitterPostClient {
136
137
elizaLogger . log ( `Next tweet scheduled in ${ randomMinutes } minutes` ) ;
137
138
} ;
138
139
139
-
140
140
const processActionsLoop = async ( ) => {
141
141
const actionInterval = parseInt (
142
142
this . runtime . getSetting ( "ACTION_INTERVAL" )
@@ -185,11 +185,13 @@ export class TwitterPostClient {
185
185
} else {
186
186
elizaLogger . log ( "Action processing loop disabled by configuration" ) ;
187
187
}
188
+ generateNewTweetLoop ( ) ;
188
189
}
189
190
190
191
constructor ( client : ClientBase , runtime : IAgentRuntime ) {
191
192
this . client = client ;
192
193
this . runtime = runtime ;
194
+ this . twitterUsername = runtime . getSetting ( "TWITTER_USERNAME" ) ;
193
195
}
194
196
195
197
private async generateNewTweet ( ) {
@@ -310,7 +312,7 @@ export class TwitterPostClient {
310
312
userId : this . client . profile . id ,
311
313
inReplyToStatusId :
312
314
tweetResult . legacy . in_reply_to_status_id_str ,
313
- permanentUrl : `https://twitter.com/${ this . runtime . getSetting ( "TWITTER_USERNAME" ) } /status/${ tweetResult . rest_id } ` ,
315
+ permanentUrl : `https://twitter.com/${ this . twitterUsername } /status/${ tweetResult . rest_id } ` ,
314
316
hashtags : [ ] ,
315
317
mentions : [ ] ,
316
318
photos : [ ] ,
@@ -432,7 +434,7 @@ export class TwitterPostClient {
432
434
433
435
await this . runtime . ensureUserExists (
434
436
this . runtime . agentId ,
435
- this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
437
+ this . twitterUsername ,
436
438
this . runtime . character . name ,
437
439
"twitter"
438
440
) ;
@@ -463,7 +465,7 @@ export class TwitterPostClient {
463
465
content : { text : "" , action : "" } ,
464
466
} ,
465
467
{
466
- twitterUserName : this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
468
+ twitterUserName : this . twitterUsername ,
467
469
currentTweet : `ID: ${ tweet . id } \nFrom: ${ tweet . name } (@${ tweet . username } )\nText: ${ tweet . text } ` ,
468
470
}
469
471
) ;
@@ -549,7 +551,7 @@ export class TwitterPostClient {
549
551
content : { text : tweet . text , action : "QUOTE" }
550
552
} ,
551
553
{
552
- twitterUserName : this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
554
+ twitterUserName : this . twitterUsername ,
553
555
currentPost : `From @${ tweet . username } : ${ tweet . text } ` ,
554
556
formattedConversation,
555
557
imageContext : imageDescriptions . length > 0
@@ -698,7 +700,7 @@ export class TwitterPostClient {
698
700
content : { text : tweet . text , action : "" }
699
701
} ,
700
702
{
701
- twitterUserName : this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
703
+ twitterUserName : this . twitterUsername ,
702
704
currentPost : `From @${ tweet . username } : ${ tweet . text } ` ,
703
705
formattedConversation,
704
706
imageContext : imageDescriptions . length > 0
0 commit comments