summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-02-24 23:52:31 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-02-26 00:39:48 +0100
commit30c4ff98d480dfd7af489a5a9998223cd4d13fa0 (patch)
tree8c857bc402e961d342d757089c86b01da39e172d /data/rbot/plugins
parent57f03b3cd65ff75684e929553d8a3d64713afd28 (diff)
markov: add config option for delay in learning thread
Diffstat (limited to 'data/rbot/plugins')
-rwxr-xr-xdata/rbot/plugins/markov.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb
index deeb9cae..4fffe564 100755
--- a/data/rbot/plugins/markov.rb
+++ b/data/rbot/plugins/markov.rb
@@ -24,6 +24,10 @@ class MarkovPlugin < Plugin
:default => 50,
:validate => Proc.new { |v| (0..100).include? v },
:desc => "Maximum number of words the bot should put in a sentence")
+ Config.register Config::IntegerValue.new('markov.learn_delay',
+ :default => 0.5,
+ :validate => Proc.new { |v| v >= 0 },
+ :desc => "Time the learning thread spends sleeping after learning a line. If set to zero, learning from files can be very CPU intensive, but also faster.")
def initialize
super
@@ -45,7 +49,7 @@ class MarkovPlugin < Plugin
@learning_thread = Thread.new do
while s = @learning_queue.pop
learn_line s
- sleep 0.5
+ sleep @bot.config['markov.learn_delay'] unless @bot.config['markov.learn_delay'].zero?
end
end
@learning_thread.priority = -1