aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-09-21 23:36:00 +1200
committerDavid Phillips <david@sighup.nz>2018-09-21 23:53:15 +1200
commit53dc3a3a10c7d81406eae60aec84028da53b2f0a (patch)
tree5c5579cfba8f7c199ee97f346a6cb55481d8bc74
parent47b4448199799aca7c0fb3e0090e244112c8959c (diff)
downloadidalius-53dc3a3a10c7d81406eae60aec84028da53b2f0a.tar.xz
Admin: Allow in-channel part without specifying channel
-rw-r--r--Plugin/Admin.pm12
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;