aboutsummaryrefslogtreecommitdiff
path: root/saxrobot
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-03-17 15:52:59 +1300
committerDavid Phillips <david@sighup.nz>2017-03-17 16:04:00 +1300
commit0c48ea15d4fbaa687ec068c610547d1c317da63c (patch)
treea8d491a90a59623547f81059295dd35464bc349d /saxrobot
parentbc0601bd2c28395f68613fd9966ea318ff93016c (diff)
downloadidalius-0c48ea15d4fbaa687ec068c610547d1c317da63c.tar.xz
Keep output in same order as trigger input
Diffstat (limited to 'saxrobot')
-rwxr-xr-xsaxrobot17
1 files changed, 6 insertions, 11 deletions
diff --git a/saxrobot b/saxrobot
index 5f2dc79..da97e47 100755
--- a/saxrobot
+++ b/saxrobot
@@ -84,17 +84,12 @@ sub irc_public {
my $me = $irc->nick_name;
my $collected_response = "";
- for (@{$config{triggers}}) {
- my ($match, $response) = split /=>/;
- # strip quotes
- $match =~ s/^[^']*'|'[^']*$//g;
- $response =~ s/^[^']*'|'[^']*$//g;
-
- # do the count
- my $repcount = () = $what =~ /$match/gi;
- if ($repcount > 0) {
- $collected_response .= $response x $repcount;
- }
+ print $config{triggers};
+ my @k = (keys %{$config{triggers}});
+ my $expression = join '|', @k;
+ print "expression: $expression\n";
+ while ($what =~ /($expression)/g) {
+ $collected_response .= $config{triggers}->{$1};
}
$irc->yield(privmsg => $channel => $collected_response) if $collected_response;