Modify the syntax of the kick command (#10)

* Modify the syntax of the kick command

* Modify the syntax of the kick command

* Beautify helpful comment
This commit is contained in:
Krokodile Glue 2017-11-09 19:26:05 -08:00 committed by Pragmatic Software
parent efe5d838f7
commit 250337927b
1 changed files with 29 additions and 20 deletions

View File

@ -233,15 +233,23 @@ sub kick_user {
($channel, $victim) = ($1, $2);
} else {
# used in channel
if(not $arguments =~ s/^(\S+)\s*//) {
return "/msg $nick Usage: kick <nick> [reason]";
if ($arguments =~ s/^(#\S+)\s+(\S+)\s*//) {
($channel, $victim) = ($1, $2);
} elsif ($arguments =~ s/^(\S+)\s*//) {
($victim, $channel) = ($1, $from);
} else {
return "/msg $nick Usage: kick [channel] <nick> [reason]";
}
$victim = $1;
$channel = $from;
}
$reason = $arguments;
# If the user is too stupid to remember the order of the arguments,
# we can help them out by seeing if they put the channel in the reason.
if ($reason =~ s/^(#\S+)\s*//) {
$channel = $1;
}
if (not length $reason) {
if (open my $fh, '<', $self->{pbot}->{registry}->get_value('general', 'module_dir') . '/insults.txt') {
my @insults = <$fh>;
@ -259,6 +267,7 @@ sub kick_user {
$self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $victim $reason");
$self->{pbot}->{chanops}->gain_ops($channel);
return "";
}