From 10ae83bef9c81cef32639b07d2a30f9ebfdc6440 Mon Sep 17 00:00:00 2001 From: Spencer Rinehart Date: Tue, 3 Mar 2009 07:33:17 -0500 Subject: 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. --- data/rbot/plugins/markov.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data') 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 -- cgit v1.2.3