Last active
August 29, 2015 14:02
-
-
Save micmmakarov/c64649fb3f6d00d418b3 to your computer and use it in GitHub Desktop.
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 'pry' | |
require 'pry-nav' | |
#CODE IS "RailsSchoolDevelop14" | |
phones = { | |
michael: '+1415PUTREALNUMBER' | |
} | |
require 'twilio-ruby' | |
require 'time' | |
account_sid = '' # your twilio keys | |
auth_token = '' | |
my_twilio_number = '+1' #write your twilio number | |
@client = Twilio::REST::Client.new account_sid, auth_token | |
def send_sms(to, message) | |
@client.account.messages.create( | |
:from => +1, #your twilio number | |
:to => to, | |
:body => message | |
) | |
end | |
story = [] | |
current_s = "I went to a bar another night." | |
story << current_s | |
phones.each do |name, number| | |
message = send_sms(number, "Add sentance to \"#{current_s}\"") | |
begin | |
answer = current_s | |
sleep 5 #seconds | |
received_messages = @client.account.messages.list | |
last_message = received_messages.map {|m| m if m.from == phones[name]}.compact.first | |
unless last_message == nil | |
if Time.parse(last_message.date_sent) > Time.parse(message.date_created) | |
answer = last_message.body | |
end | |
end | |
end while answer == current_s | |
current_s = answer | |
story << current_s | |
end | |
binding.pry | |
old_story = => ["I went to a bar another night.", | |
"And I saw a ghost", | |
"who flew through the trees, and came upon a", | |
"Alien having a beer he opened a time portal. ", | |
"He was staring at me and offered me a beer.", | |
"So of course I pounded it!", | |
"And that, kids, is how you get pound cake."] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment