From 08eeb8b97e96c261b52e55a5426893bc107daccf Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 5 Jan 2019 18:16:51 +1300 Subject: Implement no-reentry request on modules This fixes duplicate URL titles from a `title of` command, and will likely find use in future. --- Plugin/Admin.pm | 36 ++++++++++++++++++------------------ Plugin/DevNull.pm | 2 +- Plugin/Echo.pm | 2 +- Plugin/Map.pm | 2 +- Plugin/Ping.pm | 2 +- Plugin/Random.pm | 4 ++-- Plugin/Source.pm | 2 +- Plugin/Thanks.pm | 2 +- Plugin/Timezone.pm | 2 +- Plugin/URL_Title.pm | 3 ++- Plugin/Vote.pm | 8 ++++---- 11 files changed, 33 insertions(+), 32 deletions(-) (limited to 'Plugin') 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 " 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 " 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 " 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 [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 " 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 " 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 " 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 " 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 " 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); -- cgit v1.1