Created
December 28, 2011 22:26
-
-
Save no6v/1530129 to your computer and use it in GitHub Desktop.
Trace back home or user timeline
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 list_statuses(user, list, **options) | |
options = URI.encode_www_form(options) | |
get("/lists/statuses.json?slug=#{list}&owner_screen_name=#{user}&#{options}") | |
end | |
end | |
end | |
end | |
Earthquake.init do | |
tracer = ->(timeline_method, *args, **options) do | |
loop do | |
tweets = twitter.__send__(timeline_method, *args, options) | |
break if tweets.empty? | |
options.update(max_id: tweets.last["id"].pred) | |
puts_items tweets.reverse | |
break unless confirm("continue?", :y) | |
end | |
end | |
command :trace do | |
tracer[:home_timeline] | |
end | |
command :trace do |m| | |
user, list = m[1].split(?/) | |
user.delete!(?@) | |
if list | |
tracer[:list_statuses, user, list] | |
else | |
tracer[:user_timeline, screen_name: user] | |
end | |
end | |
help :trace, "trace back home or user timeline", <<-HELP | |
⚡ :trace | |
(home timeline in reverse order) | |
continue? [Yn] n | |
⚡ :trace no6v | |
(no6v's timeline in reverse order) | |
continue? [Yn] | |
(subsequent no6v's timeline) | |
continue? [Yn] n | |
⚡ | |
HELP | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment