@@ -105,7 +105,7 @@ export class TwitterInteractionClient {
105
105
const handleTwitterInteractionsLoop = ( ) => {
106
106
// Defaults to 2 minutes
107
107
const interactionInterval = ( this . state ?. TWITTER_POLL_INTERVAL || this . runtime . getSetting ( "TWITTER_POLL_INTERVAL" ) as unknown as number || 120 ) * 1000 ;
108
-
108
+
109
109
this . handleTwitterInteractions ( ) ;
110
110
setTimeout (
111
111
handleTwitterInteractionsLoop ,
@@ -131,11 +131,11 @@ export class TwitterInteractionClient {
131
131
132
132
logger . log (
133
133
"Completed checking mentioned tweets:" ,
134
- mentionCandidates . length
134
+ mentionCandidates ? .length
135
135
) ;
136
136
let uniqueTweetCandidates = [ ...mentionCandidates ] ;
137
137
// Only process target users if configured
138
- if ( ( this . state ?. TWITTER_TARGET_USERS || this . runtime . getSetting ( "TWITTER_TARGET_USERS" ) as unknown as string [ ] ) . length ) {
138
+ if ( ( this . state ?. TWITTER_TARGET_USERS || this . runtime . getSetting ( "TWITTER_TARGET_USERS" ) as unknown as string [ ] ) ? .length ) {
139
139
const TARGET_USERS =
140
140
this . state ?. TWITTER_TARGET_USERS || this . runtime . getSetting ( "TWITTER_TARGET_USERS" ) as unknown as string [ ] ;
141
141
@@ -223,6 +223,7 @@ export class TwitterInteractionClient {
223
223
) ;
224
224
}
225
225
226
+
226
227
// Sort tweet candidates by ID in ascending order
227
228
uniqueTweetCandidates = uniqueTweetCandidates
228
229
. sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
@@ -271,11 +272,11 @@ export class TwitterInteractionClient {
271
272
272
273
const thread = await buildConversationThread (
273
274
tweet ,
274
- this . client
275
+ this . client ,
275
276
) ;
276
277
277
278
const message = {
278
- content : {
279
+ content : {
279
280
text : tweet . text ,
280
281
imageUrls : tweet . photos ?. map ( photo => photo . url ) || [ ] ,
281
282
tweet : tweet ,
@@ -302,6 +303,7 @@ export class TwitterInteractionClient {
302
303
303
304
logger . log ( "Finished checking Twitter interactions" ) ;
304
305
} catch ( error ) {
306
+ console . error ( error )
305
307
logger . error ( "Error handling Twitter interactions:" , error ) ;
306
308
}
307
309
}
@@ -326,7 +328,7 @@ export class TwitterInteractionClient {
326
328
return { text : "" , action : "IGNORE" } ;
327
329
}
328
330
329
- logger . log ( "Processing Tweet: " , tweet . id ) ;
331
+ logger . log ( "handleTweet - Processing Tweet: " , tweet . id ) ;
330
332
const formatTweet = ( tweet : Tweet ) => {
331
333
return ` ID: ${ tweet . id }
332
334
From: ${ tweet . name } (@${ tweet . username } )
@@ -358,7 +360,6 @@ export class TwitterInteractionClient {
358
360
// Handle the error
359
361
logger . error ( "Error Occured during describing image: " , error ) ;
360
362
}
361
-
362
363
let state = await this . runtime . composeState ( message , {
363
364
twitterClient : this . client . twitterClient ,
364
365
twitterUserName : this . state ?. TWITTER_USERNAME || this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
@@ -427,7 +428,7 @@ export class TwitterInteractionClient {
427
428
const shouldRespond = await this . runtime . useModel ( ModelTypes . TEXT_SMALL , {
428
429
context : shouldRespondContext ,
429
430
} ) ;
430
-
431
+
431
432
if ( ! shouldRespond . includes ( "RESPOND" ) ) {
432
433
logger . log ( "Not responding to message" ) ;
433
434
return { text : "Response Decision:" , action : shouldRespond } ;
@@ -463,7 +464,7 @@ export class TwitterInteractionClient {
463
464
const responseText = await this . runtime . useModel ( ModelTypes . TEXT_LARGE , {
464
465
context,
465
466
} ) ;
466
-
467
+
467
468
const response = parseJSONObjectFromText ( responseText ) as Content ;
468
469
469
470
const removeQuotes = ( str : string ) =>
@@ -495,7 +496,7 @@ export class TwitterInteractionClient {
495
496
) ;
496
497
return memories ;
497
498
} ;
498
-
499
+
499
500
const responseMessages = [ {
500
501
id : createUniqueUuid ( this . runtime , tweet . id ) ,
501
502
userId : this . runtime . agentId ,
@@ -550,7 +551,7 @@ export class TwitterInteractionClient {
550
551
const visited : Set < string > = new Set ( ) ;
551
552
552
553
async function processThread ( currentTweet : Tweet , depth = 0 ) {
553
- logger . log ( "Processing tweet:" , {
554
+ logger . log ( "buildConversationThread - Processing tweet:" , {
554
555
id : currentTweet . id ,
555
556
inReplyToStatusId : currentTweet . inReplyToStatusId ,
556
557
depth : depth ,
0 commit comments