From 0168a87290dccb8548b4943aca6a43b1a2567a96 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 17 Sep 2018 17:50:53 +1200 Subject: Add must_id functionality back Fixes regression in acc3dd54a4c861e2cb02f0c3cb29ea40ce16f706 --- Plugin/Admin.pm | 58 ++++++++++++++++++++++++++++------------------------ Plugin/DevNull.pm | 4 ++-- Plugin/Echo.pm | 2 +- Plugin/Introspect.pm | 2 +- Plugin/Map.pm | 4 ++-- Plugin/Ping.pm | 2 +- Plugin/Random.pm | 4 ++-- Plugin/Source.pm | 2 +- Plugin/Thanks.pm | 2 +- Plugin/Timezone.pm | 2 +- 10 files changed, 43 insertions(+), 39 deletions(-) (limited to 'Plugin') 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 " 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 " 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 " 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 [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 [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 " 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 [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 " 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 " 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 " 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}}); -- cgit v1.1