diff options
author | Spencer Rinehart <anubis@overthemonkey.com> | 2009-03-03 07:33:17 -0500 |
---|---|---|
committer | Spencer Rinehart <anubis@overthemonkey.com> | 2009-03-03 11:39:56 -0500 |
commit | 10ae83bef9c81cef32639b07d2a30f9ebfdc6440 (patch) | |
tree | 508b0d3613a49150068230aaedf06233eefa5f9e | |
parent | 229f8b290e798e6f5af8d7be22d2e6c614a17fa1 (diff) |
markov: ensure messages are cleaned before learning and replying.
Lines that began with or ended with spaces were breaking the learning
thread. The call to clean_str was moved down into learn_line (and
random_markov) so that all messages, including those being learned from
files, get cleaned.
-rwxr-xr-x | data/rbot/plugins/markov.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index 676f4966..1aa1a0b2 100755 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -448,7 +448,7 @@ class MarkovPlugin < Plugin def random_markov(m, message) return unless should_talk - word1, word2 = message.split(/\s+/) + word1, word2 = clean_str(message).split(/\s+/) return unless word1 and word2 line = generate_string(word1.intern, word2.intern) return unless line @@ -494,7 +494,7 @@ class MarkovPlugin < Plugin return if ignore? m # in channel message, the kind we are interested in - message = clean_str m.plainmessage + message = m.plainmessage if m.action? message = "#{m.sourcenick} #{message}" @@ -522,7 +522,7 @@ class MarkovPlugin < Plugin def learn_line(message) # debug "learning #{message.inspect}" - wordlist = message.split(/\s+/).map { |w| w.intern } + wordlist = clean_str(message).split(/\s+/).map { |w| w.intern } return unless wordlist.length >= 2 word1, word2 = MARKER, MARKER wordlist << MARKER |