From: Giuseppe Bilotta Date: Thu, 20 Sep 2007 15:24:58 +0000 (+0000) Subject: reaction plugin: captures in regexp are now available as match1, match2, etc X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=e265413bc16aca216d20c5a01bd373427019d37a;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git reaction plugin: captures in regexp are now available as match1, match2, etc --- diff --git a/data/rbot/plugins/reaction.rb b/data/rbot/plugins/reaction.rb index a61be294..2887d574 100644 --- a/data/rbot/plugins/reaction.rb +++ b/data/rbot/plugins/reaction.rb @@ -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}"