Skip to content

Instantly share code, notes, and snippets.

@babie
Created October 26, 2013 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save babie/7169374 to your computer and use it in GitHub Desktop.
Save babie/7169374 to your computer and use it in GitHub Desktop.
module TwitterOAuth
class Client
def get_lists(user)
get("/lists/list.json?screen_name=#{user}")
end
end
end
module Earthquake::Input
def lists
@lists ||= []
end
def puts_lists
@lists.each do |list|
puts_items twitter.list_statuses(twitter.info["screen_name"], list["slug"])
end
end
end
Earthquake.init do
@lists = twitter.get_lists(twitter.info["screen_name"])
# :list funny
command %r|:list\s+([^\s\/\*]+)$|, :as => :list do |m|
puts_items twitter.list_statuses(twitter.info["screen_name"], m[1])
end
# :list babie/funny
command %r|^:list\s+([^\s]+)\/([^\s]+)$|, :as => :list do |m|
puts_items twitter.list_statuses(m[1], m[2])
end
# list *
command %r|:list\s+\*$|, :as => :list do |m|
puts_lists
end
help :list, "show list's tweets", <<-HELP
⚡ :list list
⚡ :list user/list
⚡ :list *
HELP
completion_proc = Readline.completion_proc
Readline.completion_proc = lambda do |text|
if Readline.line_buffer =~ /^:list/
@lists.map do |list|
list["uri"].slice(1..-1).gsub(%r|^#{twitter.info["screen_name"]}/|, '')
end.grep(/^#{Regexp.quote(text)}/)
else
completion_proc.call(text)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment