diff options
| -rw-r--r-- | Plugin/Admin.pm | 36 | ||||
| -rw-r--r-- | Plugin/DevNull.pm | 2 | ||||
| -rw-r--r-- | Plugin/Echo.pm | 2 | ||||
| -rw-r--r-- | Plugin/Map.pm | 2 | ||||
| -rw-r--r-- | Plugin/Ping.pm | 2 | ||||
| -rw-r--r-- | Plugin/Random.pm | 4 | ||||
| -rw-r--r-- | Plugin/Source.pm | 2 | ||||
| -rw-r--r-- | Plugin/Thanks.pm | 2 | ||||
| -rw-r--r-- | Plugin/Timezone.pm | 2 | ||||
| -rw-r--r-- | Plugin/URL_Title.pm | 3 | ||||
| -rw-r--r-- | Plugin/Vote.pm | 8 | ||||
| -rwxr-xr-x | idalius.pl | 36 | 
12 files changed, 56 insertions, 45 deletions
diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index a4847bc..a5217f7 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -66,7 +66,7 @@ sub is_admin {  }  sub nick { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: nick <new nick>" unless @arguments == 1; @@ -75,7 +75,7 @@ sub nick {  }  sub say { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: say <channel> <msg>" unless @arguments >= 2; @@ -87,7 +87,7 @@ sub say {  }  sub do_action { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: action <channel> <action text>" unless @arguments >= 2; @@ -99,7 +99,7 @@ sub do_action {  }  sub join_channel { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: join <channel1> [channel2 ...]" unless @arguments >= 1; @@ -108,7 +108,7 @@ sub join_channel {  }  sub part { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	$where = $where->[0] if ref($where) eq "ARRAY"; @@ -129,7 +129,7 @@ sub part {  }  sub mode { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	$where = $where->[0] if ref($where) eq "ARRAY"; @@ -144,7 +144,7 @@ sub mode {  }  sub kick { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	$where = $where->[0] if ref($where) eq "ARRAY"; @@ -166,7 +166,7 @@ sub kick {  }  sub topic { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: topic <new topic>" unless @arguments >= 2; @@ -179,7 +179,7 @@ sub topic {  }  sub reconnect { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided); @@ -190,7 +190,7 @@ sub reconnect {  }  sub ignore { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: ignore <nick>" unless @arguments == 1; @@ -201,7 +201,7 @@ sub ignore {  }  sub do_not_ignore { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: don't ignore <nick>" unless @arguments == 1; @@ -217,7 +217,7 @@ sub do_not_ignore {  }  sub dump_ignore { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return "Syntax: who are you ignoring?" unless @arguments == 0; @@ -226,7 +226,7 @@ sub dump_ignore {  }  sub prefix_rm { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided); @@ -240,7 +240,7 @@ sub prefix_rm {  }  sub prefix_set { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided); @@ -251,7 +251,7 @@ sub prefix_set {  }  sub exit { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: exit" unless @arguments == 0; @@ -260,12 +260,12 @@ sub exit {  }  sub dump_plugins { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return "Active plugins: " . join ", ", @{$root_config->{active_plugins}};  }  sub unload_plugin { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: unload <plugin>" unless @arguments == 1; @@ -278,7 +278,7 @@ sub unload_plugin {  }  sub load_plugin { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return unless is_admin($logger, $who, $ided);  	return "Syntax: load <plugin>" unless @arguments == 1; diff --git a/Plugin/DevNull.pm b/Plugin/DevNull.pm index 038929a..e48b458 100644 --- a/Plugin/DevNull.pm +++ b/Plugin/DevNull.pm @@ -17,7 +17,7 @@ sub configure {  }  sub hush { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	$run_command->($rest, $who, $where, $ided); diff --git a/Plugin/Echo.pm b/Plugin/Echo.pm index f5225fe..d739a60 100644 --- a/Plugin/Echo.pm +++ b/Plugin/Echo.pm @@ -13,7 +13,7 @@ sub configure {  }  sub echo { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return $rest;  } diff --git a/Plugin/Map.pm b/Plugin/Map.pm index c8708e2..40091f4 100644 --- a/Plugin/Map.pm +++ b/Plugin/Map.pm @@ -19,7 +19,7 @@ sub configure {  sub map { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my ($command, $subjects_raw) = ($rest =~ /^(.+)\s+(\[.*\])$/);  	return "Syntax: map command [item1, item2, ...]" unless $command and $subjects_raw; diff --git a/Plugin/Ping.pm b/Plugin/Ping.pm index 2cf46d5..1b43ba0 100644 --- a/Plugin/Ping.pm +++ b/Plugin/Ping.pm @@ -13,7 +13,7 @@ sub configure {  }  sub ping { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	return "$nick: pong";  } diff --git a/Plugin/Random.pm b/Plugin/Random.pm index c6ed304..26d5250 100644 --- a/Plugin/Random.pm +++ b/Plugin/Random.pm @@ -16,13 +16,13 @@ sub configure {  }  sub shuffle { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return join " ", List::Util::shuffle(@arguments);  }  sub choose { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	return (List::Util::shuffle(@arguments))[0];  }  1; diff --git a/Plugin/Source.pm b/Plugin/Source.pm index 8719305..337f73f 100644 --- a/Plugin/Source.pm +++ b/Plugin/Source.pm @@ -12,7 +12,7 @@ sub configure {  }  sub source { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my @urls = (  		"https://git.nah.nz/idalius/",  		"https://gitlab.com/dphillips/idalius"); diff --git a/Plugin/Thanks.pm b/Plugin/Thanks.pm index 0ccf319..ed1232a 100644 --- a/Plugin/Thanks.pm +++ b/Plugin/Thanks.pm @@ -16,7 +16,7 @@ sub configure {  }  sub thanks { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	my @responses = (  		"No problem", diff --git a/Plugin/Timezone.pm b/Plugin/Timezone.pm index f10b3ca..6450a6d 100644 --- a/Plugin/Timezone.pm +++ b/Plugin/Timezone.pm @@ -22,7 +22,7 @@ sub configure {  }  sub time { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $requester = (split /!/, $who)[0];  	my @known_zones = (keys %{$config->{timezone}}); diff --git a/Plugin/URL_Title.pm b/Plugin/URL_Title.pm index cb7474c..6faa689 100644 --- a/Plugin/URL_Title.pm +++ b/Plugin/URL_Title.pm @@ -98,12 +98,13 @@ sub get_title  sub get_title_cmd  { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my ($title, $error) = get_title($rest);  	$logger->($error) if $error;  	return $error if $error; +	$no_reenter->();  	return $title if $title;  } diff --git a/Plugin/Vote.pm b/Plugin/Vote.pm index 95728c8..2917b11 100644 --- a/Plugin/Vote.pm +++ b/Plugin/Vote.pm @@ -34,7 +34,7 @@ sub has_voted {  }  sub begin { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $channel = get_channel($where);  	my $nick = (split /!/, $who)[0]; @@ -48,7 +48,7 @@ sub begin {  }  sub end { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $channel = get_channel($where);  	return "No vote is in progress" unless $vote_topic{$channel}; @@ -60,7 +60,7 @@ sub end {  }  sub yes { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	my $channel = get_channel($where); @@ -73,7 +73,7 @@ sub yes {  }  sub no { -	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	my $channel = get_channel($where); @@ -117,7 +117,7 @@ sub register_command {  }  sub run_command { -	my ($command_string, $who, $where, $ided) = @_; +	my ($command_string, $who, $where, $ided, $no_reenter) = @_;  	my @arguments;  	my $owner;  	my $command_verbatim; @@ -140,7 +140,9 @@ sub run_command {  	@arguments = split /\s+/, $rest if $rest;  	my $action = $commands{$owner}{$command}; -	return $action->($irc, \&log_info, $who, $where, $ided, $rest, @arguments); +	return $action->($irc, \&log_info, $who, $where, $ided, $rest, +		sub { push @$no_reenter, $owner; }, +		@arguments);  }  # Send an effect-free client->server message as a form of ping to allegedly @@ -209,6 +211,8 @@ sub handle_common {  	my $channel = $where->[0];  	my $output; +	my @no_reenter = (); +  	$what =~ s/\s+$//g;  	# Firstly, trigger commands @@ -217,13 +221,13 @@ sub handle_common {  	my $current_nick = $irc->nick_name();  	if (!should_ignore($who) && ($config->{_}->{prefix_nick} && $no_prefix_what =~ s/^\Q$current_nick\E[:,]\s+//g ||  	    ($config->{_}->{prefix} && $no_prefix_what =~ s/^\Q$config->{_}->{prefix}//))) { -		$output = run_command($no_prefix_what, $who, $where, $ided); +		$output = run_command($no_prefix_what, $who, $where, $ided, \@no_reenter);  		$irc->yield(privmsg => $where => $output) if $output;  		strike_add($nick, $channel) if $output;  	}  	# Secondly, trigger non-command handlers -	trigger_modules($message_type, $who, $where, ($who, $where, $what, $stripped_what)); +	trigger_modules($message_type, $who, $where, \@no_reenter, ($who, $where, $what, $stripped_what));  	return;  } @@ -231,10 +235,10 @@ sub handle_common {  # Trigger applicable non-command-bound handlers in any active modules for  # a given message type, passing them only the given arguments  sub trigger_modules { -	my ($message_type, $who, $where, @arguments) = @_; +	my ($message_type, $who, $where, $no_reenter, @arguments) = @_;  	my $nick = (split /!/, $who)[0]; -	for my $handler (handlers_for($message_type, $who)) { +	for my $handler (handlers_for($message_type, $who, $no_reenter)) {  		my @base_args = (\&log_info);  		push @base_args, @arguments;  		push @base_args, $irc; @@ -248,14 +252,15 @@ sub trigger_modules {  }  # Return a list of subs capable of handling the given message type for a nick +# excluding those modules that have asked not to be reentered for this message  sub handlers_for { -	my ($message_type, $who) = @_; +	my ($message_type, $who, $no_reenter) = @_;  	my @handlers = ();  	my $nick = (split /!/, $who)[0];  	$message_type = "on_$message_type";  	for my $module (@{$config->{_}->{active_plugins}}) { -		if (module_is_enabled($module)) { +		if (!(grep {$_ eq $module} @$no_reenter) and module_is_enabled($module)) {  			if (!should_ignore($who) and $module->can($message_type)) {  				# Leave message type unchanged  			} elsif ($module->can($message_type.$ignore_suffix)) { @@ -311,34 +316,39 @@ sub irc_public {  sub irc_join {  	my ($who, $channel) = @_[ARG0 .. ARG1]; -	trigger_modules("join", $who, $channel, ($who, $channel)); +	my @empty = (); +	trigger_modules("join", $who, $channel, \@empty, ($who, $channel));  	return;  }  sub irc_part {  	my ($who, $channel, $why) = @_[ARG0 .. ARG2];  	my $nick = ( split /!/, $who )[0]; +	my @empty = ();  	my @where = ($channel); -	trigger_modules("part", $who, $channel, ($who, $channel, $why)); +	trigger_modules("part", $who, $channel, \@empty, ($who, $channel, $why));  	return;  }  sub irc_kick {  	my ($kicker, $channel, $kickee, $reason) = @_[ARG0 .. ARG3]; -	trigger_modules("kick", $kicker, $channel, ($kicker, $channel, $kickee, $reason)); +	my @empty = (); +	trigger_modules("kick", $kicker, $channel, \@empty, ($kicker, $channel, $kickee, $reason));  	return;  }  sub irc_nick {  	my ($who, $new_nick) = @_[ARG0 .. ARG1]; -	trigger_modules("nick", $who, undef, ($who, $new_nick)); +	my @empty = (); +	trigger_modules("nick", $who, undef, \@empty, ($who, $new_nick));  	return;  }  sub irc_invite {  	my ($who, $where) = @_[ARG0 .. ARG1]; -	trigger_modules("invite", $who, undef, ($who, $where)); +	my @empty = (); +	trigger_modules("invite", $who, undef, \@empty, ($who, $where));  	return;  }  | 
