Created
December 20, 2009 23:15
-
-
Save rodreegez/260686 to your computer and use it in GitHub Desktop.
a thor script that implements basic twitter functionality. (save as tnt.thor)
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
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