在一個聊天機器人,還有一個供機器人回答所確定的命令與短語,例如功能,Ruby中的隨機msg?
match /^Loggy, te amo/, :use_prefix => false
def execute(user)
if user.name.eql? 'Cquintero6'
@client.send_msg '/me besa a Carlos'
@client.send_msg 'Io también te jamón <3'
else
@client.send_msg "#{user.name}, ¿En serio crees que amaria a una basurilla como tú? Sáquese. "
end
end
當我在聊天寫「Loggy,TE AMO」,機器人的答案,取決於在用戶上。問題是,我如何製作答案清單,以便機器人選擇一個隨機答案?謝謝!
你問如何寫一個字符串數組,並選擇和隨機一個?或者你問在哪裏有一個你可以使用的「隨機短語」列表? –
如何編寫一個字符串數組,然後選擇一個機器人! Yep –
在我的回答中增加了一個ERB的例子 –