]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
reaction plugin: captures in regexp are now available as match1, match2, etc
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 20 Sep 2007 15:24:58 +0000 (15:24 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 20 Sep 2007 15:24:58 +0000 (15:24 +0000)
data/rbot/plugins/reaction.rb

index a61be294fade5bb6256c872dfb2c8e20b93f8c44..2887d574b3861eee25ca7fdf79edb8fe32f4935e 100644 (file)
@@ -197,7 +197,8 @@ class ReactionPlugin < Plugin
       "Replies can use the %%{key} syntax to access one of the following keys: " +
       "who (the user that said the trigger), bot (the bot's own nick), " +
       "target (the first word following the trigger), what (whatever follows target), " +
-      "stuff (everything that follows the trigger), match (the actual matched text)"
+      "stuff (everything that follows the trigger), match (the actual matched text), " +
+      "match1, match2, ... (the i-th capture)"
     when :list
       "reaction list [n]: lists the n-the page of programmed reactions (30 reactions are listed per page)"
     when :show
@@ -226,6 +227,9 @@ class ReactionPlugin < Plugin
       :what => what,
       :stuff => stuff
     }
+    match.to_a.each_with_index { |d, i|
+      extra[:"match#{i}"] = d
+    }
     subs = @subs.dup.merge extra
     reply = wanted.pick_reply
     debug "picked #{reply}"