【发布时间】:2017-05-20 18:02:21
【问题描述】:
我正在尝试开发的聊天机器人命令有点问题
match /^kill (.*)|^kill/, :method => :kill
def kill(user, target)
target = target
name = user.name
if target.to_s.include? name || target.to_s.empty?
require 'erb'
phrases = ["<%= name %> (gun) Se pegó un tiro porque el nestea con cloro no funcionó"]
name = user.name
target = target
random_phrase = ERB.new(phrases.sample).result(binding)
@client.send_msg random_phrase
elsif target.include? ['chat', 'todo', 'mundo']
require 'erb'
phrases = ["<%= name %> se arrechó y le cayó a tiros a todo el mundo (gun)"]
name = user.name
target = target
random_phrase = ERB.new(phrases.sample).result(binding)
@client.send_msg random_phrase
else
require 'erb'
phrases = ["<%= name %> (gun) le pegó un tiro a <%= target %> por haberle robado memes"]
name = user.name
target = target
random_phrase = ERB.new(phrases.sample).result(binding)
@client.send_msg random_phrase
end
end
这里有两个错误,但我不知道如何解决它们
#<TypeError: no implicit conversion of false into String> in `include?'
#<TypeError: no implicit conversion of Array into String> in `include?
我已经尝试了很多事情,但我无法做到这一点。
【问题讨论】: