lib/twitter_ebooks/bot.rb
def conversation(tweet)
      conv = if tweet.in_reply_to_status_id?
        @conversations[tweet.in_reply_to_status_id]
      end

      if conv.nil?
        conv = @conversations[tweet.id] || Conversation.new(self)
      end

      if tweet.in_reply_to_status_id?
        @conversations[tweet.in_reply_to_status_id] = conv
      end
      @conversations[tweet.id] = conv

      # Expire any old conversations to prevent memory growth
      @conversations.each do |k,v|
        if v != conv && Time.now - v.last_update > 3600
          @conversations.delete(k)
        end
      end

      conv
    end
# Find or create the conversation context for this tweet
# @param tweet [Twitter::Tweet]
# @return [Ebooks::Conversation]
Find or create the conversation context for this tweet
Find or create the conversation context for this tweet
def conversation(tweet)
      conv = if tweet.in_reply_to_status_id?
        @conversations[tweet.in_reply_to_status_id]
      end
      if conv.nil?
        conv = @conversations[tweet.id] || Conversation.new(self)
      end
      if tweet.in_reply_to_status_id?
        @conversations[tweet.in_reply_to_status_id] = conv
      end
      @conversations[tweet.id] = conv
      @conversations.each do |k,v|
        if v != conv && Time.now - v.last_update > 3600
          @conversations.delete(k)
        end
      end
      conv
    end
def conversation ( tweet ) conv = if tweet . in_reply_to_status_id? @conversations [ tweet . in_reply_to_status_id ] end if conv . nil? conv = @conversations [ tweet . id ] || Conversation . new ( self ) end if tweet . in_reply_to_status_id? @conversations [ tweet . in_reply_to_status_id ] = conv end @conversations [ tweet . id ] = conv @conversations . each do | k , v | if v != conv && Time . now - v . last_update > 3600 @conversations . delete ( k ) end end conv end
Find or create the conversation context for this tweet
Find or create the conversation context for this tweet
# Expire any old conversations to prevent memory growth
None
Ebooks::Conversation
tweet
None