aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-03-17 16:06:06 +1300
committerDavid Phillips <david@sighup.nz>2017-03-17 16:06:06 +1300
commit63afa0e25d793ef5304ea2ebf7f9d822f0ca76b2 (patch)
tree92e4d1546ecb4000ad7b0fd41524efc51ef054dc
parent0c48ea15d4fbaa687ec068c610547d1c317da63c (diff)
downloadidalius-63afa0e25d793ef5304ea2ebf7f9d822f0ca76b2.tar.xz
Don't use match as key; use the expression
-rwxr-xr-xsaxrobot16
1 files changed, 12 insertions, 4 deletions
diff --git a/saxrobot b/saxrobot
index da97e47..984fd7b 100755
--- a/saxrobot
+++ b/saxrobot
@@ -85,11 +85,19 @@ sub irc_public {
my $collected_response = "";
print $config{triggers};
- my @k = (keys %{$config{triggers}});
- my $expression = join '|', @k;
- print "expression: $expression\n";
+ my @expressions = (keys %{$config{triggers}});
+ my $expression = join '|', @expressions;
while ($what =~ /($expression)/g) {
- $collected_response .= $config{triggers}->{$1};
+ my $matched = $1;
+ my $key;
+ # figure out which key matched
+ foreach (@expressions) {
+ if ($matched =~ /$_/) {
+ $key = $_;
+ last;
+ }
+ }
+ $collected_response .= $config{triggers}->{$key};
}
$irc->yield(privmsg => $channel => $collected_response) if $collected_response;