diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-08-06 20:31:16 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-08-06 20:31:16 +0200 |
commit | 900623771ac00270992ab66f959ab679c09a5f1f (patch) | |
tree | 6289fb784a4088bbf906048673e4a8176f27f854 | |
parent | 0dc4cd15c81a3ae700b23d59550f1825af989b6a (diff) |
markov plugin: configurable maximum number of words
-rw-r--r-- | data/rbot/plugins/markov.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index bae70263..3339eac0 100644 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -20,6 +20,10 @@ class MarkovPlugin < Plugin Config.register Config::ArrayValue.new('markov.ignore', :default => [], :desc => "Hostmasks and channel names markov should NOT learn from (e.g. idiot*!*@*, #privchan).") + Config.register Config::IntegerValue.new('markov.max_words', + :default => 50, + :validate => Proc.new { |v| (0..100).include? v }, + :desc => "Maximum number of words the bot should put in a sentence") def initialize super @@ -55,7 +59,7 @@ class MarkovPlugin < Plugin end def generate_string(word1, word2) - # limit to max of 50 words + # limit to max of markov.max_words words output = word1 + " " + word2 # try to avoid :nonword in the first iteration @@ -67,7 +71,7 @@ class MarkovPlugin < Plugin word1, word2 = word2, word3 end - 49.times do + (@bot.config['markov.max_words'] - 1).times do wordlist = @registry["#{word1} #{word2}"] break if wordlist.empty? word3 = wordlist[rand(wordlist.length)] |