-
-
Save milligramme/7260042 to your computer and use it in GitHub Desktop.
This file contains 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
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 "#{list['name']}: #{list['description']}".c([42,37]) | |
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 | |
#{config[:prompt]} :list list | |
#{config[:prompt]} :list user/list | |
#{config[:prompt]} :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