summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-22 09:27:49 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-22 09:27:49 +0100
commit8b57372691904b7d307eec65f0491bf2a88f1f48 (patch)
tree84e9f2304bd06179eb1b92a1af62c654898e892a /data/rbot/plugins
parentbf2a5a05b86773da8351ae01d94b0fecd5c4519a (diff)
markov plugin: thread markov chain construction and use in listen()
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/markov.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb
index 60ecafec..e340d8b8 100644
--- a/data/rbot/plugins/markov.rb
+++ b/data/rbot/plugins/markov.rb
@@ -204,17 +204,18 @@ class MarkovPlugin < Plugin
wordlist = message.split(/\s+/)
return unless wordlist.length >= 2
- word1, word2 = :nonword, :nonword
- wordlist.each do |word3|
+ Thread.new do
+ word1, word2 = :nonword, :nonword
+ wordlist.each do |word3|
+ k = "#{word1} #{word2}"
+ @registry[k] = @registry[k].push(word3)
+ word1, word2 = word2, word3
+ end
k = "#{word1} #{word2}"
- @registry[k] = @registry[k].push(word3)
- word1, word2 = word2, word3
- end
- k = "#{word1} #{word2}"
- @registry[k] = @registry[k].push(:nonword)
+ @registry[k] = @registry[k].push(:nonword)
- return if m.replied?
- random_markov(m, message)
+ random_markov(m, message) unless m.replied?
+ end
end
end