diff options
author | David Phillips <david@sighup.nz> | 2017-03-17 16:06:06 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-03-17 16:06:06 +1300 |
commit | 63afa0e25d793ef5304ea2ebf7f9d822f0ca76b2 (patch) | |
tree | 92e4d1546ecb4000ad7b0fd41524efc51ef054dc /saxrobot | |
parent | 0c48ea15d4fbaa687ec068c610547d1c317da63c (diff) | |
download | idalius-63afa0e25d793ef5304ea2ebf7f9d822f0ca76b2.tar.xz |
Don't use match as key; use the expression
Diffstat (limited to 'saxrobot')
-rwxr-xr-x | saxrobot | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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; |