Skip to content

Instantly share code, notes, and snippets.

@no6v
Created December 28, 2011 22:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save no6v/1530129 to your computer and use it in GitHub Desktop.
Save no6v/1530129 to your computer and use it in GitHub Desktop.
Trace back home or user timeline
# 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