mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Factoids: look-up use_output_queue/preserve_whitespace properly
This commit is contained in:
parent
eba5766865
commit
74401977e1
@ -1112,8 +1112,12 @@ sub cmd_factfind {
|
|||||||
my $unquoted_args = $arguments;
|
my $unquoted_args = $arguments;
|
||||||
$unquoted_args =~ s/(?:\\(?!\\))//g;
|
$unquoted_args =~ s/(?:\\(?!\\))//g;
|
||||||
$unquoted_args =~ s/(?:\\\\)/\\/g;
|
$unquoted_args =~ s/(?:\\\\)/\\/g;
|
||||||
if (not defined $argtype) { $argtype = "containing '$unquoted_args'"; }
|
|
||||||
else { $argtype .= " and containing '$unquoted_args'"; }
|
if (not defined $argtype) {
|
||||||
|
$argtype = "containing '$unquoted_args'";
|
||||||
|
} else {
|
||||||
|
$argtype .= " and containing '$unquoted_args'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not defined $argtype) { return $usage; }
|
if (not defined $argtype) { return $usage; }
|
||||||
@ -1128,8 +1132,10 @@ sub cmd_factfind {
|
|||||||
eval {
|
eval {
|
||||||
use re::engine::RE2 -strict => 1;
|
use re::engine::RE2 -strict => 1;
|
||||||
my $regex;
|
my $regex;
|
||||||
if ($use_regex) { $regex = $arguments; }
|
|
||||||
else {
|
if ($use_regex) {
|
||||||
|
$regex = $arguments;
|
||||||
|
} else {
|
||||||
$regex = ($arguments =~ m/^\w/) ? '\b' : '\B';
|
$regex = ($arguments =~ m/^\w/) ? '\b' : '\B';
|
||||||
$regex .= quotemeta $arguments;
|
$regex .= quotemeta $arguments;
|
||||||
$regex .= ($arguments =~ m/\w$/) ? '\b' : '\B';
|
$regex .= ($arguments =~ m/\w$/) ? '\b' : '\B';
|
||||||
|
@ -219,6 +219,16 @@ sub interpreter {
|
|||||||
return $usage;
|
return $usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# turn on context->{use_output_queue}?
|
||||||
|
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'use_output_queue')) {
|
||||||
|
$context->{use_output_queue} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# turn on context->{preserve_whitespace}?
|
||||||
|
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'preserve_whitespace')) {
|
||||||
|
$context->{preserve_whitespace} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
# tell PBot::Core::Interpreter to prepend caller's nick to output
|
# tell PBot::Core::Interpreter to prepend caller's nick to output
|
||||||
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'add_nick')) {
|
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'add_nick')) {
|
||||||
$context->{add_nick} = 1;
|
$context->{add_nick} = 1;
|
||||||
|
@ -663,30 +663,6 @@ sub handle_result {
|
|||||||
# nothing more to do here if we have no result or keyword
|
# nothing more to do here if we have no result or keyword
|
||||||
return 0 if not length $result or not exists $context->{keyword};
|
return 0 if not length $result or not exists $context->{keyword};
|
||||||
|
|
||||||
# set preserve_whitespace and use_output_queue
|
|
||||||
# TODO: this should be in Factoids.pm and update $context's flags
|
|
||||||
|
|
||||||
my $use_output_queue = 0;
|
|
||||||
|
|
||||||
if (not $self->{pbot}->{commands}->exists($context->{keyword})) {
|
|
||||||
my @factoids = $self->{pbot}->{factoids}->{data}->find($context->{from}, $context->{keyword},
|
|
||||||
arguments => $context->{arguments},
|
|
||||||
exact_channel => 0,
|
|
||||||
exact_trigger => 0,
|
|
||||||
find_alias => 1
|
|
||||||
);
|
|
||||||
|
|
||||||
if (@factoids == 1) {
|
|
||||||
my ($chan, $trigger) = ($factoids[0]->[0], $factoids[0]->[1]);
|
|
||||||
|
|
||||||
if ($context->{preserve_whitespace} == 0) {
|
|
||||||
$context->{preserve_whitespace} = $self->{pbot}->{factoids}->{data}->{storage}->get_data($chan, $trigger, 'preserve_whitespace') // 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$use_output_queue = $self->{pbot}->{factoids}->{data}->{storage}->get_data($chan, $trigger, 'use_output_queue') // 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my $preserve_newlines = $self->{pbot}->{registry}->get_value($context->{from}, 'preserve_newlines');
|
my $preserve_newlines = $self->{pbot}->{registry}->get_value($context->{from}, 'preserve_newlines');
|
||||||
|
|
||||||
my $original_result = $result;
|
my $original_result = $result;
|
||||||
@ -711,7 +687,7 @@ sub handle_result {
|
|||||||
|
|
||||||
my $message = "And that's all I have to say about that. See $link for full text.";
|
my $message = "And that's all I have to say about that. See $link for full text.";
|
||||||
|
|
||||||
if ($use_output_queue) {
|
if ($context->{use_output_queue}) {
|
||||||
my $message = {
|
my $message = {
|
||||||
nick => $context->{nick},
|
nick => $context->{nick},
|
||||||
user => $context->{user},
|
user => $context->{user},
|
||||||
@ -732,7 +708,7 @@ sub handle_result {
|
|||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_output_queue) {
|
if ($context->{use_output_queue}) {
|
||||||
my $delay = rand(10) + 5;
|
my $delay = rand(10) + 5;
|
||||||
my $message = {
|
my $message = {
|
||||||
nick => $context->{nick},
|
nick => $context->{nick},
|
||||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4382,
|
BUILD_REVISION => 4384,
|
||||||
BUILD_DATE => "2021-09-08",
|
BUILD_DATE => "2021-09-10",
|
||||||
};
|
};
|
||||||
|
|
||||||
sub initialize {}
|
sub initialize {}
|
||||||
|
Loading…
Reference in New Issue
Block a user