Created
April 5, 2011 00:23
-
-
Save racbarn/902769 to your computer and use it in GitHub Desktop.
one more time...
This file contains hidden or 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 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
end | |
def tweet (message) | |
if message.length <= 140 | |
@client.update(message) | |
puts "Hooray! It worked." | |
else | |
puts "Your message is #{message.length - 140} characters too long! Oh my gosh!" | |
end | |
end | |
def dm (username, message) | |
# Call yoru tweet method, passing in a message | |
# that is dm username message to send | |
tweet "dm #{username} #{message}" | |
end | |
def run | |
puts "Welcome to the JSLTwitter Client" | |
command = "" | |
until command == "q" | |
puts "Enter Command:" | |
input = gets.chomp | |
command = input.split.first | |
# input = 'd username secret message' | |
if command == "t" | |
message = input.split[1..-1].join(" ") | |
tweet(message) | |
elsif command == "d" | |
username = input.split[1] | |
message = input.split[1..-1].join(" ") | |
dm(username, message) | |
else | |
puts "Sorry, I don't know how to (#{command.inspect})" | |
end | |
end | |
end | |
end | |
# Script | |
jst = JSTwitter.new | |
jst.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment