]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
markov: learn vs learn_line
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 21 Feb 2009 17:01:30 +0000 (18:01 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 22 Feb 2009 00:58:05 +0000 (01:58 +0100)
Make learn a higher-level function that queues one or more lines, and
make learn_line the low-level database access method.

data/rbot/plugins/markov.rb

index dd66ae1d99c6685c773de2473ecbca248f38a7df..62559658517883c1646403cbe6d6e7b9140b0039 100644 (file)
@@ -44,7 +44,7 @@ class MarkovPlugin < Plugin
     @learning_queue = Queue.new
     @learning_thread = Thread.new do
       while s = @learning_queue.pop
-        learn s
+        learn_line s
         sleep 0.5
       end
     end
@@ -222,6 +222,10 @@ class MarkovPlugin < Plugin
     end
   end
 
+  def learn(*lines)
+    lines.each { |l| @learning_queue.push l }
+  end
+
   def message(m)
     return if ignore? m
 
@@ -232,11 +236,11 @@ class MarkovPlugin < Plugin
       message = "#{m.sourcenick} #{message}"
     end
 
-    @learning_queue.push message
+    learn message
     random_markov(m, message) unless m.replied?
   end
 
-  def learn(message)
+  def learn_line(message)
     # debug "learning #{message}"
     wordlist = message.split(/\s+/)
     return unless wordlist.length >= 2