3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Add invite command

This commit is contained in:
Pragmatic Software 2019-12-28 23:17:15 -08:00
parent b4f63a0be4
commit 54e75d934b
2 changed files with 26 additions and 0 deletions

View File

@ -48,6 +48,29 @@ sub initialize {
$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);
$pbot->{commands}->register(sub { return $self->invite(@_) }, "invite", 10);
}
sub invite {
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
if (not length $arguments) {
return "Usage: invite [channel] <nick>";
}
# add current channel as default channel
if ($stuff->{arglist}[0] !~ m/^#/) {
if ($from =~ m/^#/) {
unshift @{$stuff->{arglist}}, $from;
} else {
return "Usage from private message: invite <channel> <nick>";
}
}
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}->gain_ops($channel);
return "";
}
sub mode {

View File

@ -126,6 +126,9 @@ sub perform_op_commands {
} elsif ($command =~ /^kick (.*?) (.*?) (.*)/i) {
$self->{pbot}->{conn}->kick($1, $2, $3) unless $1 =~ /\Q$botnick\E/i;
$self->{pbot}->{logger}->log(" executing kick on $1 $2 $3\n");
} elsif ($command =~ /^sl (.*)/i) {
$self->{pbot}->{conn}->sl($1);
$self->{pbot}->{logger}->log(" executing sl $1\n");
}
}
$self->{pbot}->{logger}->log("Done.\n");