summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-06-28 23:40:28 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-06-28 23:40:28 +0200
commit8cc5ed2d63fe1de830009586b0102fc02f07ebfb (patch)
tree6b0a174a5b0feee3d6e2fb25dff06e41c290e7c4 /data
parent13f34a595e3dca7171dc466cc6afece0ce2adcc5 (diff)
markov: strip lines before learning them
This prevents a dead loop when learning lines starting with whitespace, which could otherwise happen e.g. when learning from a file.
Diffstat (limited to 'data')
-rwxr-xr-xdata/rbot/plugins/markov.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb
index 8ccb0caf..0475ab4d 100755
--- a/data/rbot/plugins/markov.rb
+++ b/data/rbot/plugins/markov.rb
@@ -637,7 +637,7 @@ class MarkovPlugin < Plugin
def learn_line(message)
# debug "learning #{message.inspect}"
- wordlist = message.split(/\s+/).reject do |w|
+ wordlist = message.strip.split(/\s+/).reject do |w|
@bot.config['markov.ignore_patterns'].map do |pat|
w =~ Regexp.new(pat.to_s)
end.select{|v| v}.size != 0