From bc0601bd2c28395f68613fd9966ea318ff93016c Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 17 Mar 2017 15:13:47 +1300 Subject: Improve configuration syntax --- saxrobot | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'saxrobot') diff --git a/saxrobot b/saxrobot index 599d4e8..5f2dc79 100755 --- a/saxrobot +++ b/saxrobot @@ -83,15 +83,20 @@ sub irc_public { my $me = $irc->nick_name; - # FIXME tidy this loop: do we need $idx? - my $idx = 0; - for (@{$config{re}}) { - my $repcount = () = $what =~ /@{$config{re}}[$idx]/gi; + 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) { - $irc->yield(privmsg => $channel => @{$config{rep}}[$idx] x $repcount); + $collected_response .= $response x $repcount; } - $idx++; } + $irc->yield(privmsg => $channel => $collected_response) if $collected_response; return; } -- cgit v1.1