3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

ChanOpCommands: invite now behaves more like ChanServ when used from /msg

This commit is contained in:
Pragmatic Software 2020-01-14 18:55:20 -08:00
parent 41ae04d291
commit ebf5206ff6

View File

@ -58,20 +58,37 @@ sub initialize {
sub invite { sub invite {
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_; my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
if (not length $arguments) { my ($channel, $target);
return "Usage: invite [channel] <nick>";
}
# add current channel as default channel if ($from !~ m/^#/) {
if ($stuff->{arglist}[0] !~ m/^#/) { # from /msg
if ($from =~ m/^#/) { if (not length $arguments) {
$self->{pbot}->{interpreter}->unshift_arg($stuff->{arglist}, $from); return "Usage from /msg: invite <channel> [nick]; if you omit [nick] then you will be invited";
} else {
return "Usage from private message: invite <channel> <nick>";
} }
($channel, $target) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
if ($channel !~ m/^#/) {
return "$channel is not a channel; usage from /msg: invite <channel> [nick]; if you omit [nick] then you will be invited";
}
if (not defined $target) {
$target = $nick;
}
} else {
# in channel
if (not length $arguments) {
return "Usage: invite [channel] <nick>";
}
# add current channel as default channel
if ($stuff->{arglist}[0] !~ m/^#/) {
$self->{pbot}->{interpreter}->unshift_arg($stuff->{arglist}, $from);
}
($channel, $target) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
} }
my ($channel, $target) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
$self->{pbot}->{chanops}->add_op_command($channel, "sl invite $target $channel"); $self->{pbot}->{chanops}->add_op_command($channel, "sl invite $target $channel");
$self->{pbot}->{chanops}->gain_ops($channel); $self->{pbot}->{chanops}->gain_ops($channel);
return ""; return "";