File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -176,14 +176,22 @@ export async function sendTweet(
176176 const maxTweetLength = client . twitterConfig . MAX_TWEET_LENGTH ;
177177 const isLongTweet = maxTweetLength > 280 ;
178178
179- const parentTweet = await client . twitterClient . getTweet ( inReplyTo ) ;
180- const thread = parentTweet . thread ;
181- elizaLogger . log (
182- `Replying to thread with conversation length: ${ thread . length } ` ,
183- ) ;
179+ let currentTweetId = inReplyTo ;
180+ let depth = 0 ;
181+
182+ while ( currentTweetId ) {
183+ const parentTweet = await client . twitterClient . getTweet ( currentTweetId ) ;
184+ if ( ! parentTweet || ! parentTweet . inReplyToStatusId ) {
185+ break ;
186+ }
187+ currentTweetId = parentTweet . inReplyToStatusId ;
188+ depth ++ ;
189+ }
190+
191+ elizaLogger . log ( `Replying to thread with conversation depth: ${ depth } ` ) ;
184192
185- if ( thread . length > MAX_CONVERSATION_LENGTH ) {
186- elizaLogger . error ( "Reply conversation length is too long" ) ;
193+ if ( depth > MAX_CONVERSATION_LENGTH ) {
194+ elizaLogger . error ( "Reply conversation depth is too long" ) ;
187195 return [ ] ;
188196 }
189197
You can’t perform that action at this time.
0 commit comments