3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-02-18 14:30:40 +01:00

Interpreter: support give nick cmd [args] command

This commit is contained in:
Pragmatic Software 2020-05-31 15:32:56 -07:00
parent 158b13006c
commit 0692f2614a

View File

@ -219,6 +219,19 @@ sub interpret {
delete $context->{nickoverride}; delete $context->{nickoverride};
delete $context->{force_nickoverride}; delete $context->{force_nickoverride};
} }
} elsif ($self->arglist_size($cmdlist) >= 3 and lc $cmdlist->[0] eq 'give') {
# give nick cmd [args]
$context->{nickoverride} = $cmdlist->[1];
($keyword, $arguments) = $self->split_args($cmdlist, 2, 2, 1);
$arguments = '' if not defined $arguments;
my $similar = $self->{pbot}->{nicklist}->is_present_similar($context->{from}, $context->{nickoverride});
if ($similar) {
$context->{nickoverride} = $similar;
$context->{force_nickoverride} = 1;
} else {
delete $context->{nickoverride};
delete $context->{force_nickoverride};
}
} else { } else {
# normal command # normal command
($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1); ($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1);
@ -508,6 +521,8 @@ sub split_line {
%opts = (%default_opts, %opts); %opts = (%default_opts, %opts);
return () if not length $line;
my @chars = split //, $line; my @chars = split //, $line;
my @args; my @args;
@ -816,8 +831,9 @@ sub handle_result {
my $cmdlist = $self->make_args($context->{command}); my $cmdlist = $self->make_args($context->{command});
my ($cmd, $args) = $self->split_args($cmdlist, 2, 0, 1); my ($cmd, $args) = $self->split_args($cmdlist, 2, 0, 1);
if (not $self->{pbot}->{commands}->exists($cmd)) { if (not $self->{pbot}->{commands}->exists($cmd)) {
my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($context->{from}, $cmd, arguments => $args, exact_channel => 1, exact_trigger => 0, find_alias => 1); my @factoids = $self->{pbot}->{factoids}->find_factoid($context->{from}, $cmd, arguments => $args, exact_channel => 0, exact_trigger => 0, find_alias => 1);
if (defined $trigger) { if (@factoids == 1) {
my ($chan, $trigger) = ($factoids[0]->[0], $factoids[0]->[1]);
if ($context->{preserve_whitespace} == 0) { if ($context->{preserve_whitespace} == 0) {
$context->{preserve_whitespace} = $self->{pbot}->{factoids}->{factoids}->get_data($chan, $trigger, 'preserve_whitespace') // 0; $context->{preserve_whitespace} = $self->{pbot}->{factoids}->{factoids}->get_data($chan, $trigger, 'preserve_whitespace') // 0;
} }
@ -865,8 +881,12 @@ sub handle_result {
if ($use_output_queue) { if ($use_output_queue) {
my $delay = rand(10) + 5; my $delay = rand(10) + 5;
my $message = { my $message = {
nick => $context->{nick}, user => $context->{user}, host => $context->{host}, command => $context->{command}, nick => $context->{nick},
message => $line, checkflood => 1 user => $context->{user},
host => $context->{host},
command => $context->{command},
message => $line,
checkflood => 1,
}; };
$self->add_message_to_output_queue($context->{from}, $message, $delay); $self->add_message_to_output_queue($context->{from}, $message, $delay);
$delay = duration($delay); $delay = duration($delay);