aboutsummaryrefslogtreecommitdiff
path: root/saxrobot
diff options
context:
space:
mode:
Diffstat (limited to 'saxrobot')
-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;