Skip to content

Instantly share code, notes, and snippets.

@rodreegez
Created December 20, 2009 23:15
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 rodreegez/260686 to your computer and use it in GitHub Desktop.
Save rodreegez/260686 to your computer and use it in GitHub Desktop.
a thor script that implements basic twitter functionality. (save as tnt.thor)
require 'rubygems'
require 'thor'
require 'twitter'
class TNT < Thor
map "MESSAGE" => :post
desc "post \"message\"", "Post a message to Twitter"
def post(message)
client.update message
end
map "recent" => :recent
desc "recent", "Get recent tweets from the folks you follow"
def recent
f = client.friends_timeline
f.each { |t| puts "#{t.user.screen_name}:\n #{t.text}" }
end
map "dms" => :dms
desc "Direct Messages", "Get your DMs"
def dms
client.direct_messages.each do |d|
puts "#{d.sender_screen_name}:\n #{d.text}"
puts
end
end
no_tasks{
def httpauth
Twitter::HTTPAuth.new('your_username', 'your_pass')
end
def client
Twitter::Base.new(httpauth)
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment