X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Ffactoids.rb;h=ba6e88453b7d40ac11018400fc1614b5c335227a;hb=4fa049e0386d8044f0063e90b7e7efbca9c712de;hp=3192aa00e450d211de79f7aa9a0cad1ca944a5ac;hpb=63eaa1da3ba602e55458ad2228b8ecc9db045b04;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb index 3192aa00..ba6e8845 100644 --- a/data/rbot/plugins/factoids.rb +++ b/data/rbot/plugins/factoids.rb @@ -120,7 +120,7 @@ class FactoidsPlugin < Plugin super # TODO config - @dir = File.join(@bot.botclass,"factoids") + @dir = datafile @filename = "factoids.rbot" @factoids = FactoidList.new @triggers = Set.new @@ -341,7 +341,7 @@ class FactoidsPlugin < Plugin if params[:words].nil_or_empty? and params[:rx].nil_or_empty? m.reply _("I know %{total} facts" % { :total => total }) else - if params[:words].empty? + unless params.key? :words and not params[:words].empty? rx = Regexp.new(params[:rx].to_s, true) else rx = words2rx(params[:words]) @@ -349,7 +349,11 @@ class FactoidsPlugin < Plugin known = @factoids.grep(rx) reply = [] if known.empty? - reply << _("I know nothing about %{words}" % params) + if params.key? :words + reply << _("I know nothing about %{words}" % params) + else params.key? :rx + reply << _("I know nothing matching %{rx}" % params) + end else max_facts = @bot.config['factoids.search_results'] len = known.length @@ -379,7 +383,12 @@ class FactoidsPlugin < Plugin 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