From a7866c12500840e189d069b510352adff72e7093 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 26 Dec 2019 06:08:39 -0800 Subject: [PATCH] ChanOpCommands: add `mode` command (level 40) --- PBot/ChanOpCommands.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/PBot/ChanOpCommands.pm b/PBot/ChanOpCommands.pm index 38dc7cc9..49913853 100644 --- a/PBot/ChanOpCommands.pm +++ b/PBot/ChanOpCommands.pm @@ -47,6 +47,31 @@ sub initialize { $pbot->{commands}->register(sub { return $self->kick_user(@_) }, "kick", 10); $pbot->{commands}->register(sub { return $self->checkban(@_) }, "checkban", 0); $pbot->{commands}->register(sub { return $self->checkmute(@_) }, "checkmute", 0); + $pbot->{commands}->register(sub { return $self->mode(@_) }, "mode", 40); +} + +sub mode { + my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_; + + if (not length $arguments) { + return "Usage: mode [channel] "; + } + + # add current channel as default channel + if ($stuff->{arglist}[0] !~ m/^#/) { + if ($from =~ m/^#/) { + unshift @{$stuff->{arglist}}, $from; + } else { + return "Usage from private message: mode "; + } + } + + my ($channel, $args) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2); + $self->{pbot}->{conn}->mode($channel, $args); + + if ($from !~ m/^#/) { + return "Done."; + } } sub checkban {