# encoding: utf-8
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'
# put your own credentials here
account_sid = 'ABCABCABCABCABCABCABCABCABCABCABC'#GET YOUR OWN TOKENS FROM TWILIO
auth_token = 'ABCABCABCABCABCABCABCABCABCABCABC' #GET YOUR OWN TOKENS FROM TWILIO
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
def text(message = 'BOOM')
@client.account.messages.create(
:from => '+18885551212', #GET YOUR OWN NUMBER FROM TWILIO
:to => '+13335251234', #VERIFY YOUR PHONE NUMBER TO TWILIO
:body => message)
end
@previous_level = :empty
def handle_input(input)
if @previous_level == input
else
@previous_level = input
new_input(input)
end
end
def new_input(input)
case input
when 'w'
text('The glass is full!')
when 's'
text('The glass is half full')
when 'a'
text('The glass is almost empty')
else
text("some DIRT")
end
end
begin
system("stty raw -echo")
loop do
handle_input STDIN.getc
end
ensure
system("stty -raw echo")
end