3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 12:29:27 +01:00

kick command now provides random insult if no kick reason is given

This commit is contained in:
Pragmatic Software 2016-08-28 22:36:46 -07:00
parent c93d3db39c
commit eff8046f2c

View File

@ -185,26 +185,39 @@ sub kick_user {
return ""; return "";
} }
# used in private message my ($channel, $victim, $reason);
if(not $from =~ /^#/) { if(not $from =~ /^#/) {
if(not $arguments =~ /(^#\S+) (\S+) (.*)/) { # used in private message
$self->{pbot}->{logger}->log("$nick!$user\@$host: invalid arguments to kick\n"); if(not $arguments =~ s/^(^#\S+) (\S+)\s*//) {
return "/msg $nick Usage from private message: kick <channel> <nick> <reason>"; return "/msg $nick Usage from private message: kick <channel> <nick> [reason]";
} }
$self->{pbot}->{chanops}->add_op_command($1, "kick $1 $2 $3"); ($channel, $victim) = ($1, $2);
$self->{pbot}->{chanops}->gain_ops($1); } else {
return "/msg $nick Kicking $2 from $1 with reason '$3'";
}
# used in channel # used in channel
if(not $arguments =~ /(.*?) (.*)/) { if(not $arguments =~ s/^(\S+)\s*//) {
$self->{pbot}->{logger}->log("$nick!$user\@$host: invalid arguments to kick\n"); return "/msg $nick Usage: kick <nick> [reason]";
return "/msg $nick Usage: kick <nick> <reason>"; }
$victim = $1;
$channel = $from;
} }
$self->{pbot}->{chanops}->add_op_command($from, "kick $from $1 $2"); $reason = $arguments;
$self->{pbot}->{chanops}->gain_ops($from);
return "/msg $nick Kicking $1 from $from with reason '$2'"; if (not length $reason) {
if (open my $fh, '<', $self->{pbot}->{registry}->get_value('general', 'module_dir') . '/insults.txt') {
my @insults = <$fh>;
close $fh;
$reason = $insults[rand @insults];
chomp $reason;
} else {
$reason = 'Bye!';
}
}
$self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $victim $reason");
$self->{pbot}->{chanops}->gain_ops($channel);
return "/msg $nick Kicking $victim channel $channel with reason '$reason'";
} }
1; 1;