Created
November 14, 2017 01:30
-
-
Save oieioi/5b56a8a90a46bdf51bcba57bcbe5d225 to your computer and use it in GitHub Desktop.
Earthquake plugin to search back
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
Earthquake.once do | |
module TwitterOAuth | |
class Client | |
def search_queries(q, **options) | |
q = URI.encode_www_form_component(q) | |
options = URI.encode_www_form(options) | |
get("/search/tweets.json?q=#{q}&#{options}") | |
end | |
end | |
end | |
end | |
Earthquake.init do | |
tracer = ->(timeline_method, *args, **options) do | |
loop do | |
results = twitter.__send__(timeline_method, *args, options) | |
tweets = results["statuses"] | |
break if tweets.empty? | |
options.update(max_id: tweets.last["id"].pred) | |
puts_items tweets.reverse | |
break unless confirm("continue?", :y) | |
end | |
end | |
command :search_trace do |m| | |
q = m[1] | |
tracer[:search_queries, q] | |
end | |
help :s_trace, "trace back search result", <<-HELP | |
HELP | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
forked from https://gist.github.com/no6v/1530129