Skip to content

Instantly share code, notes, and snippets.

@racbarn
Created April 4, 2011 22:41
Show Gist options
  • Save racbarn/902623 to your computer and use it in GitHub Desktop.
Save racbarn/902623 to your computer and use it in GitHub Desktop.
the whole thing :)
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)
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
when 'dm'then dm(parts[1], parts[1..-1].join(" "))
puts "d, " ", jumpstartfoundry, " ", this is a tweet for jsf"
end
end
# Script
jst = JSTwitter.new
jst.run
@jcasimir
Copy link

jcasimir commented Apr 4, 2011

Try working with this:

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

@jcasimir
Copy link

jcasimir commented Apr 4, 2011

That sucked, let me make a new gist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment