diff options
author | David Phillips <david@sighup.nz> | 2018-09-21 23:36:00 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-09-21 23:53:15 +1200 |
commit | 53dc3a3a10c7d81406eae60aec84028da53b2f0a (patch) | |
tree | 5c5579cfba8f7c199ee97f346a6cb55481d8bc74 | |
parent | 47b4448199799aca7c0fb3e0090e244112c8959c (diff) | |
download | idalius-53dc3a3a10c7d81406eae60aec84028da53b2f0a.tar.xz |
Admin: Allow in-channel part without specifying channel
-rw-r--r-- | Plugin/Admin.pm | 12 |
1 files changed, 11 insertions, 1 deletions
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 <channel1> [channel2 ...] [partmsg]" unless @arguments >= 1; + return "Syntax: part <channel1> [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; |