]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
markov plugin: don't echo a line a line that is just a substring of the input line
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 6 Aug 2008 18:40:40 +0000 (20:40 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 6 Aug 2008 18:40:40 +0000 (20:40 +0200)
data/rbot/plugins/markov.rb

index 3339eac0db071d1a844c0e6dd513ebeafb5d92c9..9b83e53a56d0f6b85a1f4558431cb8045a32d331 100644 (file)
@@ -183,7 +183,9 @@ class MarkovPlugin < Plugin
     return unless word1 and word2
     line = generate_string(word1, word2)
     return unless line
-    return if line == message
+    # we do nothing if the line we return is just an initial substring
+    # of the line we received
+    return if message.index(line) == 0
     @bot.timer.add_once(delay) {
       m.reply line
     }