Skip to content

Instantly share code, notes, and snippets.

@jcasimir
Forked from racbarn/gist:902623
Created April 4, 2011 22:48
Show Gist options
  • Select an option

  • Save jcasimir/902635 to your computer and use it in GitHub Desktop.

Select an option

Save jcasimir/902635 to your computer and use it in GitHub Desktop.
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 run
puts "Welcome to the JSLTwitter Client"
command = ""
until command == "q"
puts "Enter Command:"
input = gets.chomp
command = input.split.first
message = input.split[1..-1].join(" ")
if command =="t"
tweet(message)
elsif command == "d"
dm("jumpstartfoundry", "secret message")
else
puts "Sorry, I don't know how to (#{command.inspect})"
end
end
end
def dm(target, message)
puts "Trying to send #{target} this direct message:"
puts message
tweet("???")
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