Created
June 26, 2012 01:47
-
-
Save jackieiscool/2992650 to your computer and use it in GitHub Desktop.
TWITTER SOME MORE
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 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
end | |
def tweet(message) | |
if message.length > 140 | |
remainder = message[0..-141] | |
@client.update(message[-140..-1]) | |
self.tweet(remainder) | |
else | |
@client.update(message) | |
end | |
end | |
def run | |
input = "" | |
while input != "q" | |
print "gimmi a command['say', 'q', 'dm' ]:" | |
input = gets.chomp | |
parts = input.split | |
command = parts[0] | |
case command | |
when 'q' then puts "Goodbye!" | |
when 'say' then tweet(parts[1..-1].join(" ")) | |
when 'dm' then dm(parts[1], parts[2..-1].join(" ")) | |
else | |
puts "Sorry, I don't know that command." | |
end | |
end | |
end | |
def dm(target, message) | |
puts "Trying to send #{target} this direct message:" | |
puts message | |
end | |
end | |
jst = JSTwitter.new | |
jst.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment