Skip to content

Instantly share code, notes, and snippets.

@oieioi
Created November 14, 2017 01:30
Show Gist options
  • Save oieioi/5b56a8a90a46bdf51bcba57bcbe5d225 to your computer and use it in GitHub Desktop.
Save oieioi/5b56a8a90a46bdf51bcba57bcbe5d225 to your computer and use it in GitHub Desktop.
Earthquake plugin to search back
# 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
@oieioi
Copy link
Author

oieioi commented Nov 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment