@@ -105,7 +105,7 @@ export class TwitterInteractionClient {
105105 const handleTwitterInteractionsLoop = ( ) => {
106106 // Defaults to 2 minutes
107107 const interactionInterval = ( this . state ?. TWITTER_POLL_INTERVAL || this . runtime . getSetting ( "TWITTER_POLL_INTERVAL" ) as unknown as number || 120 ) * 1000 ;
108-
108+
109109 this . handleTwitterInteractions ( ) ;
110110 setTimeout (
111111 handleTwitterInteractionsLoop ,
@@ -131,11 +131,11 @@ export class TwitterInteractionClient {
131131
132132 logger . log (
133133 "Completed checking mentioned tweets:" ,
134- mentionCandidates . length
134+ mentionCandidates ? .length
135135 ) ;
136136 let uniqueTweetCandidates = [ ...mentionCandidates ] ;
137137 // 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 ) {
139139 const TARGET_USERS =
140140 this . state ?. TWITTER_TARGET_USERS || this . runtime . getSetting ( "TWITTER_TARGET_USERS" ) as unknown as string [ ] ;
141141
@@ -223,6 +223,7 @@ export class TwitterInteractionClient {
223223 ) ;
224224 }
225225
226+
226227 // Sort tweet candidates by ID in ascending order
227228 uniqueTweetCandidates = uniqueTweetCandidates
228229 . sort ( ( a , b ) => a . id . localeCompare ( b . id ) )
@@ -271,11 +272,11 @@ export class TwitterInteractionClient {
271272
272273 const thread = await buildConversationThread (
273274 tweet ,
274- this . client
275+ this . client ,
275276 ) ;
276277
277278 const message = {
278- content : {
279+ content : {
279280 text : tweet . text ,
280281 imageUrls : tweet . photos ?. map ( photo => photo . url ) || [ ] ,
281282 tweet : tweet ,
@@ -302,6 +303,7 @@ export class TwitterInteractionClient {
302303
303304 logger . log ( "Finished checking Twitter interactions" ) ;
304305 } catch ( error ) {
306+ console . error ( error )
305307 logger . error ( "Error handling Twitter interactions:" , error ) ;
306308 }
307309 }
@@ -326,7 +328,7 @@ export class TwitterInteractionClient {
326328 return { text : "" , action : "IGNORE" } ;
327329 }
328330
329- logger . log ( "Processing Tweet: " , tweet . id ) ;
331+ logger . log ( "handleTweet - Processing Tweet: " , tweet . id ) ;
330332 const formatTweet = ( tweet : Tweet ) => {
331333 return ` ID: ${ tweet . id }
332334 From: ${ tweet . name } (@${ tweet . username } )
@@ -358,7 +360,6 @@ export class TwitterInteractionClient {
358360 // Handle the error
359361 logger . error ( "Error Occured during describing image: " , error ) ;
360362}
361-
362363 let state = await this . runtime . composeState ( message , {
363364 twitterClient : this . client . twitterClient ,
364365 twitterUserName : this . state ?. TWITTER_USERNAME || this . runtime . getSetting ( "TWITTER_USERNAME" ) ,
@@ -427,7 +428,7 @@ export class TwitterInteractionClient {
427428 const shouldRespond = await this . runtime . useModel ( ModelTypes . TEXT_SMALL , {
428429 context : shouldRespondContext ,
429430 } ) ;
430-
431+
431432 if ( ! shouldRespond . includes ( "RESPOND" ) ) {
432433 logger . log ( "Not responding to message" ) ;
433434 return { text : "Response Decision:" , action : shouldRespond } ;
@@ -463,7 +464,7 @@ export class TwitterInteractionClient {
463464 const responseText = await this . runtime . useModel ( ModelTypes . TEXT_LARGE , {
464465 context,
465466 } ) ;
466-
467+
467468 const response = parseJSONObjectFromText ( responseText ) as Content ;
468469
469470 const removeQuotes = ( str : string ) =>
@@ -495,7 +496,7 @@ export class TwitterInteractionClient {
495496 ) ;
496497 return memories ;
497498 } ;
498-
499+
499500 const responseMessages = [ {
500501 id : createUniqueUuid ( this . runtime , tweet . id ) ,
501502 userId : this . runtime . agentId ,
@@ -550,7 +551,7 @@ export class TwitterInteractionClient {
550551 const visited : Set < string > = new Set ( ) ;
551552
552553 async function processThread ( currentTweet : Tweet , depth = 0 ) {
553- logger . log ( "Processing tweet:" , {
554+ logger . log ( "buildConversationThread - Processing tweet:" , {
554555 id : currentTweet . id ,
555556 inReplyToStatusId : currentTweet . inReplyToStatusId ,
556557 depth : depth ,
0 commit comments