def determin_response body
body = body.downcase.strip
media = nil
if str_check body,"hi"
message = "Hi, I am Mr Coin🤖. What can I do for you?"
media = "https://media.giphy.com/media/g0ym52S4egOMqG9oPY/giphy.gif"
elsif str_check body,"who"
message = "I'm Mr Coin🤖. I can flip a coin to help you make decision. I am also a coin expert! You can ask me anything about coin."
elsif str_check body,"what"
message = "I can flip a coin to make decision for you. Also I am a coin expert!You can ask me anything about coin."
elsif str_check body,"how"
message = "Type #️⃣flip to flip a coin. \n Type #️⃣funfact to get a fun fact about coin. \n Type #️⃣game to start a guess game!"
elsif str_check body,"when"
message = "I was made in Fall 2018 by Lingzhi Li on Programing for Online Prototype Course."
elsif str_check body,"why"
message = "That's a good question🤔. Where am I from?"
elsif str_check body, "flip"
message = $coin_sides.sample
elsif str_check body,"joke"
#File.open("jokes.txt","r")
array_of_lines = IO.readlines("jokes.txt")
message = "there is a funny joke, " + array_of_lines.sample #retun is compulsory
#File.close
elsif str_check body, "fact"
#File.open("facts.txt","r")
array_of_lines = IO.readlines("facts.txt")
message = "I found a fun fact about coin! \n" + array_of_lines.sample
#File.close #not sure if "file" should be uppercase
elsif str_check body, "game"
message = "let's play the game! I have flipped a coin🤛. Type 'heads' or 'tails' to take a guess!"
elsif str_check body, "heads"
message = guess_game "heads", $right_answer
elsif str_check body, "tails"
message = guess_game "tails", $right_answer
elsif str_check body, "bye"
message = "Nice to talk to you. Enjoy your Mini 1 break!!! Bye👋"
else message = $comfort_reply.sample
end
return message, media
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. .