lib/chatterbot/search.rb in chatterbot-0.2.8 vs lib/chatterbot/search.rb in chatterbot-0.2.9
- old
+ new
@@ -2,10 +2,17 @@
#
# handle Twitter searches
module Search
+ #
+ # modify a query string to exclude retweets from searches
+ #
+ def exclude_retweets(q)
+ 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}"
@@ -16,16 +23,21 @@
#
# search twitter
#
queries.each { |query|
- search = client.search(query, opts.merge(default_opts))
+ debug "search: #{query} #{opts.merge(default_opts)}"
+
+ search = client.search(exclude_retweets(query), opts.merge(default_opts))
update_since_id(search)
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
}
end