diff options
| author | David Phillips <david@sighup.nz> | 2017-03-17 15:13:47 +1300 | 
|---|---|---|
| committer | David Phillips <david@sighup.nz> | 2017-03-17 15:13:47 +1300 | 
| commit | bc0601bd2c28395f68613fd9966ea318ff93016c (patch) | |
| tree | 3cf2b100aedff62df6a0471df5c086018809a2d9 /saxrobot | |
| parent | 39757ff46ec4ea773f7d41df62e3b98e3a4e73df (diff) | |
| download | idalius-bc0601bd2c28395f68613fd9966ea318ff93016c.tar.xz | |
Improve configuration syntax
Diffstat (limited to 'saxrobot')
| -rwxr-xr-x | saxrobot | 17 | 
1 files changed, 11 insertions, 6 deletions
| @@ -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;  } | 
