From 53dc3a3a10c7d81406eae60aec84028da53b2f0a Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 21 Sep 2018 23:36:00 +1200 Subject: Admin: Allow in-channel part without specifying channel --- Plugin/Admin.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Plugin') diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index b1245d6..b4c4768 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -44,6 +44,10 @@ sub configure { return $self; } +sub is_channel { + return @_[0] =~ m/^#+/; +} + sub is_admin { my ($logger, $who, $ided) = @_; if ($config->{must_id} and not $ided) { @@ -103,7 +107,13 @@ sub part { my ($self, $irc, $logger, $who, $where, $ided, $rest, @arguments) = @_; return unless is_admin($logger, $who, $ided); - return "Syntax: part [channel2 ...] [partmsg]" unless @arguments >= 1; + return "Syntax: part [channel2 ...] [partmsg]" unless + is_channel($where->[0]) or + (@arguments >= 1 and is_channel($arguments[0])); + + if ((@arguments == 0 and is_channel($where->[0])) or @arguments >= 1 and not is_channel($arguments[0])) { + $rest = "$where->[0] $rest"; + } my $nick = (split /!/, $who)[0]; my ($chan_str, $reason) = split /\s+(?!#)/, $rest, 2; -- cgit v1.1