lib/chatterbot/search.rb in chatterbot-0.5.1 vs lib/chatterbot/search.rb in chatterbot-0.6.1

- old
+ new

@@ -11,12 +11,10 @@ q.include?("include:retweets") ? q : q += " -include:retweets" end # internal search code def search(queries, opts = {}, &block) - return unless init_client - debug "check for tweets since #{since_id}" if queries.is_a?(String) queries = [queries] end @@ -24,22 +22,20 @@ # # search twitter # queries.each { |query| debug "search: #{query} #{opts.merge(default_opts)}" - - search = client.search(exclude_retweets(query), opts.merge(default_opts)) - update_since_id(search) + result = search_client.search( + exclude_retweets(query), + opts.merge(default_opts) + ) - if search != nil - search["results"].each { |s| - s.symbolize_keys! - debug s[:text] - #if s[:text].downcase.include?(query.downcase) - yield s unless ! block_given? || on_blacklist?(s) || skip_me?(s) - #end - } - end + update_since_id(result.max_id) + + result.collection.each { |s| + debug s.text + yield s unless ! block_given? || on_blacklist?(s) || skip_me?(s) + } } end end end