]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/keywords.rb
fix: update deprecated git option
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / keywords.rb
index 8671e32f89a58806ef583ad08cfdc5ce47514f04..ecb6cca85cecfd6bde062c1e525a1bd1c705db03 100644 (file)
@@ -138,7 +138,7 @@ class Keywords < Plugin
   # have been added
   def scan
     # first scan for old DBHash files, and convert them
-    Dir[datafile '*'].each {|f|
+    Dir[datafile('*')].each {|f|
       next unless f =~ /\.db$/
       log "upgrading keyword db #{f} (rbot 0.9.5 or prior) database format"
       newname = f.gsub(/\.db$/, ".kdb")
@@ -153,7 +153,7 @@ class Keywords < Plugin
     }
 
     # then scan for current DBTree files, and load them
-    Dir[@bot.path 'keywords', '*'].each {|f|
+    Dir[@bot.path('keywords', '*')].each {|f|
       next unless f =~ /\.kdb$/
       hsh = DBTree.new @bot, f, true
       key = File.basename(f).gsub(/\.kdb$/, "")
@@ -162,7 +162,7 @@ class Keywords < Plugin
     }
 
     # then scan for non DB files, and convert/import them and delete
-    Dir[@bot.path 'keywords', '*'].each {|f|
+    Dir[@bot.path('keywords', '*')].each {|f|
       next if f =~ /\.kdb$/
       next if f =~ /CVS$/
       log "auto converting keywords from #{f}"
@@ -202,7 +202,7 @@ class Keywords < Plugin
       File.rename(olds, olds + ".old")
     end
 
-    olds.replace(@bot.path 'keyword.db')
+    olds.replace(@bot.path('keyword.db'))
     if File.exist? olds
       log "upgrading old keywords (rbot 0.9.9 or prior) database format"
       old = BDB::CIBtree.open olds, nil, "r+", 0600
@@ -221,7 +221,7 @@ class Keywords < Plugin
   end
 
   def oldsave
-    File.open(@bot.path "keywords.rbot", "w") do |file|
+    File.open(@bot.path("keywords.rbot"), "w") do |file|
       @keywords.each do |key, value|
         file.puts "#{key}<=#{value.type}=>#{value.dump}"
       end
@@ -325,6 +325,10 @@ class Keywords < Plugin
     case plugin
     when /keyword/
       case topic
+      when 'stats'
+        'keyword stats => show statistics about static facts'
+      when 'wipe'
+        'keyword wipe <keyword> => forgets everything about a keyword'
       when 'lookup'
         'keyword [lookup] <keyword> => look up the definition for a keyword; writing "lookup" is optional'
       when 'set'
@@ -348,7 +352,7 @@ class Keywords < Plugin
       when '<topic>'
         '<topic> => respond by setting the topic to the rest of the definition'
       else
-        'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, <reply>, <action>, <who>, <topic>'
+        'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, stats, export, wipe, <reply>, <action>, <who>, <topic>'
       end
     when "forget"
       'forget <keyword> => forget a keyword'
@@ -468,41 +472,11 @@ class Keywords < Plugin
     m.reply "done"
   end
 
-  # export keywords to factoids file
-  def keyword_factoids_export
-    ar = Array.new
-
-    debug @keywords.keys
-
-    @keywords.each { |k, val|
-      next unless val
-      kw = Keyword.restore(val)
-      ar |= kw.to_factoids(k)
-    }
-
-    # TODO check factoids config
-    # also TODO: runtime export
-    dir = @bot.path 'factoids'
-    fname = File.join(dir,"keyword_factoids.rbot")
-
-    Dir.mkdir(dir) unless FileTest.directory?(dir)
-    Utils.safe_save(fname) do |file|
-      file.puts ar
-    end
-  end
-
   # privmsg handler
   def privmsg(m)
     case m.plugin
     when "keyword"
       case m.params
-      when /^export$/
-        begin
-          keyword_factoids_export
-          m.okay
-        rescue
-          m.reply _("failed to export keywords as factoids (%{err})" % {:err => $!})
-        end
       when /^set\s+(.+?)\s+(is|are)\s+(.+)$/
         keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto)
       when /^forget\s+(.+)$/