if session[:lastquestion] != 0
array_of_lines = IO.readlines("responses.txt")
array_of_lines.each do |line|
items = []
items = line.split( ";")
question = items[0] # question
response1 = items[1]
response2 = items[2]
reply = items[3]
if (session[:lastquestion] == question) && (items[2] != nil)
# response here...
if (body.include? response1) or (body.include? response2)
message = reply
media = search_giphy_for ("happy")
#session[:lastquestion] = 0
else
message = "I think I will choose " + items[1]
media = search_giphy_for ("confused")
#session[:lastquestion] = 0
end
end
end
session[:lastquestion] = 0
else
sigh_words=["... ", "Em.... ", "Hm... "]
array_of_lines = IO.readlines("responses.txt")
sampled = array_of_lines.sample.to_s
items = []
items = sampled.split( ";")
question = items[0] # question
response1 = items[1]
response2 = items[2]
reply = items[3]
session[:lastquestion] = items[0]
media = search_giphy_for ("confused")
message = sigh_words.sample.to_s + session[:lastquestion].to_s
end
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .