super
# TODO config
- @dir = File.join(@bot.botclass,"factoids")
+ @dir = datafile
@filename = "factoids.rbot"
@factoids = FactoidList.new
@triggers = Set.new
# When looking for words we separate them with
# arbitrary whitespace, not whatever they came with
pre = words.map { |w| Regexp.escape(w)}.join("\\s+")
- return Regexp.new("\\b#{pre}\\b", true)
+ pre << '\b' if pre.match(/\b$/)
+ pre = '\b' + pre if pre.match(/^\b/)
+ return Regexp.new(pre, true)
end
def facts(m, params)
return if @triggers.empty?
query = $1.strip.downcase
if @triggers.include?(query)
- facts(m, :words => query.split)
+ words = query.split
+ words.instance_variable_set(:@string_value, query)
+ def words.to_s
+ @string_value
+ end
+ facts(m, :words => words)
end
else
return if m.address? # we don't learn stuff directed at us which is not an explicit learn command