mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
Add $0 in factoid action to expand to first keyword used to invoke factoid
This commit is contained in:
parent
d0f837ee94
commit
1a08156443
@ -88,7 +88,7 @@ sub exists {
|
|||||||
|
|
||||||
sub interpreter {
|
sub interpreter {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, $unused, $referenced) = @_;
|
my ($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, $unused, $referenced, $root_keyword) = @_;
|
||||||
my $result;
|
my $result;
|
||||||
|
|
||||||
my $pbot = $self->{pbot};
|
my $pbot = $self->{pbot};
|
||||||
|
@ -524,7 +524,7 @@ sub expand_action_arguments {
|
|||||||
|
|
||||||
sub interpreter {
|
sub interpreter {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, $ref_from, $referenced) = @_;
|
my ($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, $ref_from, $referenced, $root_keyword) = @_;
|
||||||
my ($result, $channel);
|
my ($result, $channel);
|
||||||
my $pbot = $self->{pbot};
|
my $pbot = $self->{pbot};
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ sub interpreter {
|
|||||||
# if there's just one other channel that has this keyword, trigger that instance
|
# if there's just one other channel that has this keyword, trigger that instance
|
||||||
elsif($found == 1) {
|
elsif($found == 1) {
|
||||||
$pbot->{logger}->log("Found '$original_keyword' as '$fwd_trig' in [$fwd_chan]\n");
|
$pbot->{logger}->log("Found '$original_keyword' as '$fwd_trig' in [$fwd_chan]\n");
|
||||||
return $pbot->{factoids}->interpreter($from, $nick, $user, $host, ++$depth, $fwd_trig, $arguments, $tonick, $fwd_chan, $referenced);
|
return $pbot->{factoids}->interpreter($from, $nick, $user, $host, ++$depth, $fwd_trig, $arguments, $tonick, $fwd_chan, $referenced, $root_keyword);
|
||||||
}
|
}
|
||||||
# otherwise keyword hasn't been found, display similiar matches for all channels
|
# otherwise keyword hasn't been found, display similiar matches for all channels
|
||||||
else {
|
else {
|
||||||
@ -761,7 +761,7 @@ sub interpreter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pbot->{logger}->log("[" . (defined $from ? $from : "stdin") . "] ($nick!$user\@$host) [$keyword] aliased to: [$command]\n");
|
$pbot->{logger}->log("[" . (defined $from ? $from : "stdin") . "] ($nick!$user\@$host) [$keyword] aliased to: [$command]\n");
|
||||||
return $pbot->{interpreter}->interpret($from, $nick, $user, $host, $depth, $command, $tonick, $referenced);
|
return $pbot->{interpreter}->interpret($from, $nick, $user, $host, $depth, $command, $tonick, $referenced, $root_keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined $tonick) { # !tell foo about bar
|
if(defined $tonick) { # !tell foo about bar
|
||||||
@ -797,6 +797,7 @@ sub interpreter {
|
|||||||
$action =~ s/\$nick/$nick/g;
|
$action =~ s/\$nick/$nick/g;
|
||||||
$action =~ s/\$channel/$from/g;
|
$action =~ s/\$channel/$from/g;
|
||||||
$action =~ s/\$randomnick/my $random = $self->{pbot}->{nicklist}->random_nick($from); $random ? $random : $nick/ge;
|
$action =~ s/\$randomnick/my $random = $self->{pbot}->{nicklist}->random_nick($from); $random ? $random : $nick/ge;
|
||||||
|
$action =~ s/\$0\b/$root_keyword/g;
|
||||||
|
|
||||||
if($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') {
|
if($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') {
|
||||||
my $preserve_whitespace = $self->{factoids}->hash->{$channel}->{$keyword}->{preserve_whitespace};
|
my $preserve_whitespace = $self->{factoids}->hash->{$channel}->{$keyword}->{preserve_whitespace};
|
||||||
@ -862,7 +863,7 @@ sub interpreter {
|
|||||||
$cmd = $action;
|
$cmd = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $pbot->{interpreter}->interpret($from, $nick, $user, $host, $depth, $cmd, $tonick, $referenced);
|
$result = $pbot->{interpreter}->interpret($from, $nick, $user, $host, $depth, $cmd, $tonick, $referenced, $root_keyword);
|
||||||
return $result;
|
return $result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ sub process_line {
|
|||||||
|
|
||||||
sub interpret {
|
sub interpret {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($from, $nick, $user, $host, $depth, $command, $tonick, $referenced) = @_;
|
my ($from, $nick, $user, $host, $depth, $command, $tonick, $referenced, $root_keyword) = @_;
|
||||||
my ($keyword, $arguments) = ("", "");
|
my ($keyword, $arguments) = ("", "");
|
||||||
my $text;
|
my $text;
|
||||||
my $pbot = $self->{pbot};
|
my $pbot = $self->{pbot};
|
||||||
@ -231,7 +231,7 @@ sub interpret {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self->SUPER::execute_all($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, undef, $referenced);
|
return $self->SUPER::execute_all($from, $nick, $user, $host, $depth, $keyword, $arguments, $tonick, undef, $referenced, defined $root_keyword ? $root_keyword : $keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub truncate_result {
|
sub truncate_result {
|
||||||
|
Loading…
Reference in New Issue
Block a user