lib/chatterbot/streaming.rb in chatterbot-2.0.3 vs lib/chatterbot/streaming.rb in chatterbot-2.0.4
- old
+ new
@@ -5,10 +5,20 @@
module Streaming
def streaming_tweet_handler
usable_handlers = [:home_timeline, :search]
name, block = @handlers.find { |k, v| usable_handlers.include?(k) }
- block
+
+ if block.nil? && ( block = @handlers[:replies] )
+ debug "No default handler, wrapping the replies handler"
+ return Proc.new { |tweet|
+ if tweet.text =~ /^@#{bot.screen_name}/i
+ block.call(tweet)
+ end
+ }
+ end
+
+ block
end
#
# Take the passed in object and call the appropriate bot method
# for it