]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/markov.rb
[registry] fix subregistry re-use (closes #1)
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / markov.rb
old mode 100755 (executable)
new mode 100644 (file)
index 21c4d63..eb9294e
@@ -183,6 +183,9 @@ class MarkovPlugin < Plugin
     @upgrade_queue.push nil
 
     @upgrade_thread = Thread.new do
+      @registry.recovery = Proc.new { |val|
+        return [val]
+      }
       logfile = File.open(@bot.path('markov-conversion.log'), 'a')
       logfile.puts "=== conversion thread started #{Time.now} ==="
       while k = @upgrade_queue.pop
@@ -199,6 +202,7 @@ class MarkovPlugin < Plugin
       end
       logfile.puts "=== conversion thread stopped #{Time.now} ==="
       logfile.close
+      @registry.recovery = nil
     end
     @upgrade_thread.priority = -1
   end
@@ -362,8 +366,12 @@ class MarkovPlugin < Plugin
       else
         "markov chat => try to say something intelligent"
       end
+    when "learn"
+      ["markov learn from <file> [testing [<num> lines]] [using pattern <pattern>]:",
+       "learn from the text in the specified <file>, optionally using the given <pattern> to filter the text.",
+       "you can sample what would be learned by specifying 'testing <num> lines'"].join(' ')
     else
-      "markov plugin: listens to chat to build a markov chain, with which it can (perhaps) attempt to (inanely) contribute to 'discussion'. Sort of.. Will get a *lot* better after listening to a lot of chat. Usage: 'chat' to attempt to say something relevant to the last line of chat, if it can -- help topics: ignore, readonly, delay, status, probability, chat, chat about"
+      "markov plugin: listens to chat to build a markov chain, with which it can (perhaps) attempt to (inanely) contribute to 'discussion'. Sort of.. Will get a *lot* better after listening to a lot of chat. Usage: 'chat' to attempt to say something relevant to the last line of chat, if it can -- help topics: ignore, readonly, delay, status, probability, chat, chat about, learn"
     end
   end