mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 10:34:52 +01:00
Factoids: root keyword can now be overridden
This commit is contained in:
parent
1f6d655a3e
commit
1ff38eaacc
@ -280,6 +280,12 @@ sub find_factoid {
|
|||||||
|
|
||||||
$self->{pbot}->{logger}->log("from: $from\n") if $debug;
|
$self->{pbot}->{logger}->log("from: $from\n") if $debug;
|
||||||
|
|
||||||
|
if ($keyword =~ /^([^ ]+) (.*)/) {
|
||||||
|
$self->{pbot}->{logger}->log("chopping keyword\n");
|
||||||
|
$keyword = $1;
|
||||||
|
$arguments = $2;
|
||||||
|
}
|
||||||
|
|
||||||
my @result = eval {
|
my @result = eval {
|
||||||
my @results;
|
my @results;
|
||||||
for (my $depth = 0; $depth < 5; $depth++) {
|
for (my $depth = 0; $depth < 5; $depth++) {
|
||||||
@ -947,7 +953,9 @@ sub handle_action {
|
|||||||
my $ref_from = $stuff->{ref_from} ? "[$stuff->{ref_from}] " : "";
|
my $ref_from = $stuff->{ref_from} ? "[$stuff->{ref_from}] " : "";
|
||||||
|
|
||||||
unless (exists $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} and $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
|
unless (exists $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} and $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
|
||||||
$action = $self->expand_factoid_vars($stuff->{from}, $stuff->{nick}, $stuff->{root_keyword}, $action);
|
my $kw = length $self->{factoids}->hash->{$channel}->{$stuff->{root_keyword}}->{keyword_override} ? $self->{factoids}->hash->{$channel}->{$stuff->{root_keyword}}->{keyword_override} : $stuff->{root_keyword};
|
||||||
|
$kw = $stuff->{keyword_override} if length $stuff->{keyword_override};
|
||||||
|
$action = $self->expand_factoid_vars($stuff->{from}, $stuff->{nick}, $kw, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length $stuff->{arguments}) {
|
if (length $stuff->{arguments}) {
|
||||||
@ -984,6 +992,10 @@ sub handle_action {
|
|||||||
my $command = $1;
|
my $command = $1;
|
||||||
$command .= " $stuff->{original_arguments}" if length $stuff->{original_arguments} and not $stuff->{aliased};
|
$command .= " $stuff->{original_arguments}" if length $stuff->{original_arguments} and not $stuff->{aliased};
|
||||||
|
|
||||||
|
if ($command =~ s/\s*--keyword-override=([^ ]+)\s*//) {
|
||||||
|
$stuff->{keyword_override} = $1;
|
||||||
|
}
|
||||||
|
|
||||||
$stuff->{command} = $command;
|
$stuff->{command} = $command;
|
||||||
$stuff->{aliased} = 1;
|
$stuff->{aliased} = 1;
|
||||||
|
|
||||||
@ -999,7 +1011,9 @@ sub handle_action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unless (exists $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} and $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
|
unless (exists $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} and $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
|
||||||
$action = $self->expand_factoid_vars($stuff->{from}, $stuff->{nick}, $stuff->{root_keyword}, $action);
|
my $kw = length $self->{factoids}->hash->{$channel}->{$stuff->{root_keyword}}->{keyword_override} ? $self->{factoids}->hash->{$channel}->{$stuff->{root_keyword}}->{keyword_override} : $stuff->{root_keyword};
|
||||||
|
$kw = $stuff->{keyword_override} if length $stuff->{keyword_override};
|
||||||
|
$action = $self->expand_factoid_vars($stuff->{from}, $stuff->{nick}, $kw, $action);
|
||||||
$action = $self->expand_action_arguments($action, $stuff->{arguments}, $stuff->{nick});
|
$action = $self->expand_action_arguments($action, $stuff->{arguments}, $stuff->{nick});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user