original_docstring:  Loop for tweeting, while the stream is open. 
docstring: Loop for tweeting, while the stream is open.
docstring_tokens: Loop for tweeting while the stream is open .
code: def _tweet_loop(self):
          """ Loop for tweeting, while the stream is open. """
          next_index = LoadFromFile.load_last_feed_index(self.config.filenames['stats'])
  
          while self.running:
              # Get next tweet(s) ready
              next_tweets, feed_length = (
                  LoadFromFile.tweets_at(next_index, self.config.filenames['feed'])
              )
              next_index += 1
  
              if not next_tweets:
                  log(BotEvents.SYS.ThreadStop, "Tweet loop: tweets_at() failed")
                  self.running = False
                  break
  
              # Sleep until time in config
              next_time = self.get_next_tweet_datetime()
              if next_time:
                  delta = next_time - datetime.datetime.now()
              else:
                  log(BotEvents.SYS.ThreadStop, "Tweet loop: get_next_tweet_datetime() failed")
                  self.running = False
                  break
  
              print("Wait for {} seconds".format(delta.total_seconds()))
              sleep(delta.total_seconds()) # > WAIT FOR NEXT TWEET TIME <<<<<<<<<<<<<<<<<<<<<<<<<<
              log_str = "{} tweet{} starting at {} ({})".format(
                  len(next_tweets),
                  's' if (len(next_tweets) > 1) else '',
                  next_index,
                  next_tweets[-1]['title']
                  )
              log(BotEvents.SYS.LoadTweet, log_str)
              print(log_str)
  
              # Submit each tweet in chain (or just one, if not a chain)
              if BotFunctions.TweetOnline in self.functionality:
                  for tweet in next_tweets:
                      self.api.update_status(
                          '{}\n{} of {}'.format(tweet['text'], next_index, feed_length)
                      )
                      next_index += 1
                      sleep(self.config.min_tweet_delay.TWEET_DELAY)
              self.update_feed_index(next_index)
          # Running loop ended
          log(BotEvents.SYS.ThreadStop, "Tweet loop ended.")
code_tokens: def _tweet_loop ( self ) : next_index = LoadFromFile . load_last_feed_index ( self . config . filenames [ 'stats' ] ) while self . running : next_tweets , feed_length = ( LoadFromFile . tweets_at ( next_index , self . config . filenames [ 'feed' ] ) ) next_index += 1 if not next_tweets : log ( BotEvents . SYS . ThreadStop , "Tweet loop: tweets_at() failed" ) self . running = False break next_time = self . get_next_tweet_datetime ( ) if next_time : delta = next_time - datetime . datetime . now ( ) else : log ( BotEvents . SYS . ThreadStop , "Tweet loop: get_next_tweet_datetime() failed" ) self . running = False break print ( "Wait for {} seconds" . format ( delta . total_seconds ( ) ) ) sleep ( delta . total_seconds ( ) ) log_str = "{} tweet{} starting at {} ({})" . format ( len ( next_tweets ) , 's' if ( len ( next_tweets ) > 1 ) else '' , next_index , next_tweets [ - 1 ] [ 'title' ] ) log ( BotEvents . SYS . LoadTweet , log_str ) print ( log_str ) if BotFunctions . TweetOnline in self . functionality : for tweet in next_tweets : self . api . update_status ( '{}\n{} of {}' . format ( tweet [ 'text' ] , next_index , feed_length ) ) next_index += 1 sleep ( self . config . min_tweet_delay . TWEET_DELAY ) self . update_feed_index ( next_index ) log ( BotEvents . SYS . ThreadStop , "Tweet loop ended." )
short_docstring: Loop for tweeting, while the stream is open.
short_docstring_tokens: Loop for tweeting while the stream is open .
comment: """ Loop for tweeting, while the stream is open. """$SEP$# Get next tweet(s) ready$SEP$# Sleep until time in config$SEP$# > WAIT FOR NEXT TWEET TIME <<<<<<<<<<<<<<<<<<<<<<<<<<$SEP$# Submit each tweet in chain (or just one, if not a chain)$SEP$# Running loop ended