diff options
| author | David Phillips <david@sighup.nz> | 2018-09-17 17:50:53 +1200 | 
|---|---|---|
| committer | David Phillips <david@sighup.nz> | 2018-09-17 17:51:02 +1200 | 
| commit | 0168a87290dccb8548b4943aca6a43b1a2567a96 (patch) | |
| tree | 59f657c45c3e0aeca7586c07808a67430e499b66 | |
| parent | acc3dd54a4c861e2cb02f0c3cb29ea40ce16f706 (diff) | |
| download | idalius-0168a87290dccb8548b4943aca6a43b1a2567a96.tar.xz | |
Add must_id functionality back
Fixes regression in acc3dd54a4c861e2cb02f0c3cb29ea40ce16f706
| -rw-r--r-- | Plugin/Admin.pm | 58 | ||||
| -rw-r--r-- | Plugin/DevNull.pm | 4 | ||||
| -rw-r--r-- | Plugin/Echo.pm | 2 | ||||
| -rw-r--r-- | Plugin/Introspect.pm | 2 | ||||
| -rw-r--r-- | Plugin/Map.pm | 4 | ||||
| -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 | ||||
| -rwxr-xr-x | idalius.pl | 14 | 
11 files changed, 50 insertions, 46 deletions
diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index 3e600fb..622f772 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -31,28 +31,31 @@ sub configure {  }  sub is_admin { -	my $who = shift; +	my ($logger, $who, $ided) = @_; +	if ($config->{must_id} and not $ided) { +		$logger->("$who hasn't identified, but tried to use a command"); +		return 0; +	}  	my $is_admin = grep {$_ eq $who} @{$config->{admins}};  	if (!$is_admin) { -		# FIXME log this rather than print -		print "$who isn't an admin, but tried to use a command\n"; +		$logger->("$who isn't an admin, but tried to use a command");  	}  	return $is_admin;  }  sub nick { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: nick <new nick>" unless @arguments == 1;  	$irc->yield(nick => $arguments[0]);  }  sub say { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: say <channel> <msg>" unless @arguments >= 2;  	# Strip nick/channel from message @@ -62,9 +65,9 @@ sub say {  }  sub do_action { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: action <channel> <action text>" unless @arguments >= 2;  	# Strip nick/channel from message @@ -74,18 +77,18 @@ sub do_action {  }  sub join_channel { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: join <channel1> [channel2 ...]" unless @arguments >= 1;  	$irc->yield(join => $_) for @arguments;  }  sub part { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: part <channel1> [channel2 ...] [partmsg]" unless @arguments >= 1;  	my $nick = (split /!/, $who)[0]; @@ -96,9 +99,9 @@ sub part {  }  sub mode { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: mode <everything>" unless @arguments > 0;  	# FIXME should use $where if it's a channel (?) @@ -106,9 +109,9 @@ sub mode {  }  sub kick { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: kick <channel> <nick> [reason]" unless @arguments >= 2;  	# FIXME should use $where if it's a channel (?) @@ -121,9 +124,9 @@ sub kick {  }  sub topic { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: topic <new topic>" unless @arguments >= 2;  	# Strip nick/channel from message @@ -134,18 +137,18 @@ sub topic {  }  sub reconnect { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	my $reason = $rest;  	$irc->yield(quit => $reason);  }  sub ignore { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: ignore <nick>" unless @arguments == 1;  	push @{$config->{ignore}}, $arguments[0]; @@ -154,9 +157,9 @@ sub ignore {  }  sub do_not_ignore { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	return unless is_admin($who); +	return unless is_admin($logger, $who, $ided);  	return "Syntax: don't ignore <nick>" unless @arguments == 1;  	my $target = $arguments[0]; @@ -170,7 +173,7 @@ sub do_not_ignore {  }  sub dump_ignore { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	return "Syntax: who are you ignoring?" unless @arguments == 0; @@ -179,8 +182,9 @@ sub dump_ignore {  }  sub exit { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; +	return unless is_admin($logger, $who, $ided);  	return "Syntax: exit" unless @arguments == 0;  	exit; diff --git a/Plugin/DevNull.pm b/Plugin/DevNull.pm index 0565aec..b1087f1 100644 --- a/Plugin/DevNull.pm +++ b/Plugin/DevNull.pm @@ -17,9 +17,9 @@ sub configure {  }  sub hush { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; -	$run_command->($rest, $who, $where); +	$run_command->($rest, $who, $where, $ided);  	return;  } diff --git a/Plugin/Echo.pm b/Plugin/Echo.pm index 2cd59fc..ba66c48 100644 --- a/Plugin/Echo.pm +++ b/Plugin/Echo.pm @@ -13,7 +13,7 @@ sub configure {  }  sub echo { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	return $rest;  } diff --git a/Plugin/Introspect.pm b/Plugin/Introspect.pm index 4c53984..05f338a 100644 --- a/Plugin/Introspect.pm +++ b/Plugin/Introspect.pm @@ -18,7 +18,7 @@ sub configure {  }  sub dump_plugins { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	return "Plugins: " . join ", ", $root_config->{plugins};  }  1; diff --git a/Plugin/Map.pm b/Plugin/Map.pm index 1e24f9c..42856eb 100644 --- a/Plugin/Map.pm +++ b/Plugin/Map.pm @@ -19,7 +19,7 @@ sub configure {  sub map { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	my ($command, $subjects_raw) = ($rest =~ /^(.+)\s+(\[.*\])$/);  	return "Syntax: map command [item1, item2, ...]" unless $command and $subjects_raw; @@ -27,7 +27,7 @@ sub map {  	my ($e, @subjects) = ListParser::parse_list($subjects_raw);  	return $e if $e; -	my @results = map { $run_command->("$command $_", $who, $where) } @subjects; +	my @results = map { $run_command->("$command $_", $who, $where, $ided) } @subjects;  	return "[" . (join ", ", @results). "]";  }  1; diff --git a/Plugin/Ping.pm b/Plugin/Ping.pm index 43e42b6..efb55ce 100644 --- a/Plugin/Ping.pm +++ b/Plugin/Ping.pm @@ -15,7 +15,7 @@ sub configure {  }  sub ping { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	return "$nick: pong";  } diff --git a/Plugin/Random.pm b/Plugin/Random.pm index 27332f8..cea65fb 100644 --- a/Plugin/Random.pm +++ b/Plugin/Random.pm @@ -16,13 +16,13 @@ sub configure {  }  sub shuffle { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	return join " ", List::Util::shuffle(@arguments);  }  sub choose { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	return (List::Util::shuffle(@arguments))[0];  }  1; diff --git a/Plugin/Source.pm b/Plugin/Source.pm index e3774e9..6b93979 100644 --- a/Plugin/Source.pm +++ b/Plugin/Source.pm @@ -12,7 +12,7 @@ sub configure {  }  sub source { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	my @urls = (  		"https://git.nah.nz/idalius/",  		"https://gitlab.com/dphillips/idalius"); diff --git a/Plugin/Thanks.pm b/Plugin/Thanks.pm index e40e3ef..01c52ac 100644 --- a/Plugin/Thanks.pm +++ b/Plugin/Thanks.pm @@ -16,7 +16,7 @@ sub configure {  }  sub thanks { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	my $nick = (split /!/, $who)[0];  	my @responses = (  		"No problem", diff --git a/Plugin/Timezone.pm b/Plugin/Timezone.pm index 90db1fb..c679340 100644 --- a/Plugin/Timezone.pm +++ b/Plugin/Timezone.pm @@ -19,7 +19,7 @@ sub configure {  }  sub time { -	my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; +	my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_;  	my $requester = (split /!/, $who)[0];  	my @known_zones = (keys %{$config->{timezone}}); @@ -102,7 +102,7 @@ sub register_command {  }  sub run_command { -	my ($command_string, $who, $where) = @_; +	my ($command_string, $who, $where, $ided) = @_;  	my @arguments;  	my $command_verbatim;  	my $command; @@ -119,7 +119,7 @@ sub run_command {  	my $rest = (split "\Q$command_verbatim", $command_string, 2)[1];  	@arguments = split /\s+/, $rest if $rest; -	return ($commands{$command})->($irc, \&log_info, $who, $where, $rest, @arguments); +	return ($commands{$command})->($irc, \&log_info, $who, $where, $ided, $rest, @arguments);  }  sub custom_ping { @@ -198,7 +198,7 @@ sub irc_kick {  }  sub handle_common { -	my ($message_type, $who, $where, $what) = @_; +	my ($message_type, $who, $where, $what, $ided) = @_;  	my $nick = (split /!/, $who)[0];  	my $channel = $where->[0];  	my $output; @@ -209,7 +209,7 @@ sub handle_common {  	my $no_prefix_what = $stripped_what;  	if (!should_ignore($nick) && ($config->{_}->{prefix_nick} && $no_prefix_what =~ s/^\Q$current_nick\E[:,]\s+//g ||  	    $no_prefix_what =~ s/^$config->{_}->{prefix}//)) { -		$output = run_command($no_prefix_what, $who, $where); +		$output = run_command($no_prefix_what, $who, $where, $ided);  		$irc->yield(privmsg => $where => $output) if $output;  		strike_add($nick, $channel) if $output;  	} @@ -248,13 +248,13 @@ sub irc_ctcp_action {  }  sub irc_public { -	my ($sender, $who, $where, $what) = @_[SENDER, ARG0 .. ARG2]; +	my ($who, $where, $what, $ided) = @_[ARG0 .. ARG3];  	my $nick = ( split /!/, $who )[0];  	my $channel = $where->[0];  	log_info("[$channel] $who: $what"); -	return handle_common("message", $who, $where, $what); +	return handle_common("message", $who, $where, $what, $ided);  }  sub irc_msg { @@ -262,7 +262,7 @@ sub irc_msg {  	my $nick = (split /!/, $who)[0];  	my $stripped_what = strip_color(strip_formatting($what)); -	my $output = run_command($stripped_what, $who, $nick); +	my $output = run_command($stripped_what, $who, $nick, $ided);  	$irc->yield(privmsg => $nick => $output) if $output;  	return;  | 
