mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Allow "nick: !command" to address to nick; minor improvements
This commit is contained in:
parent
4764b034e1
commit
8addeb5d49
@ -616,6 +616,15 @@ sub interpreter {
|
||||
} else {
|
||||
if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'text') {
|
||||
my $target = $self->{pbot}->{nicklist}->is_present_similar($from, $arguments);
|
||||
|
||||
if (not $target) {
|
||||
if ($arguments =~ m/\$/) {
|
||||
$target = $arguments;
|
||||
} elsif ($action !~ m{^/call\s}) {
|
||||
return "/me blinks at $nick.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($target and $action !~ /\$nick/) {
|
||||
if ($action !~ m/^(\/[^ ]+) /) {
|
||||
$action =~ s/^/\/say $target: $keyword is / unless defined $tonick;
|
||||
|
@ -99,7 +99,7 @@ sub process_line {
|
||||
if ($cmd_text =~ s/\B$bot_trigger`([^`]+)// || $cmd_text =~ s/\B$bot_trigger\{([^}]+)//) {
|
||||
my $cmd = $1;
|
||||
my ($nick) = $cmd_text =~ m/^([^ ,:;]+)/;
|
||||
$nick = $self->{pbot}->{nicklist}->is_present_similar($from, $nick);
|
||||
$nick = $self->{pbot}->{nicklist}->is_present($from, $nick);
|
||||
if ($nick) {
|
||||
$command = "tell $nick about $cmd";
|
||||
} else {
|
||||
@ -117,8 +117,20 @@ sub process_line {
|
||||
my $similar = $self->{pbot}->{nicklist}->is_present_similar($from, $nick_override);
|
||||
$nick_override = $similar if $similar;
|
||||
$processed += 100;
|
||||
} elsif($cmd_text =~ s/^$bot_trigger(.*)$//) {
|
||||
$command = $1;
|
||||
} elsif($cmd_text =~ s/^\s*([^,:\(\)\+\*\/ ]+)?[,:]*\s*$bot_trigger(.*)$//) {
|
||||
$nick_override = $1;
|
||||
$command = $2;
|
||||
|
||||
if (defined $nick_override) {
|
||||
my $similar = $self->{pbot}->{nicklist}->is_present_similar($from, $nick_override);
|
||||
if ($similar) {
|
||||
$nick_override = $similar;
|
||||
} else {
|
||||
$self->{pbot}->{logger}->log("No similar nick for $nick_override\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$processed += 100;
|
||||
} elsif($cmd_text =~ s/^.?$botnick.?\s*(.*?)$//i) {
|
||||
$command = $1;
|
||||
@ -148,7 +160,7 @@ sub process_line {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$processed++ if $self->handle_result($from, $nick, $user, $host, $text, $command, $self->interpret($from, $nick, $user, $host, 1, $command, undef, $referenced), 1, $preserve_whitespace);
|
||||
$processed++ if $self->handle_result($from, $nick, $user, $host, $text, $command, $self->interpret($from, $nick, $user, $host, 1, $command, $nick_override, $referenced), 1, $preserve_whitespace);
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
|
@ -126,9 +126,7 @@ sub is_present_similar {
|
||||
|
||||
return 0 if not exists $self->{nicklist}->{$channel};
|
||||
return $self->{nicklist}->{$channel}->{$nick}->{nick} if $self->is_present($channel, $nick);
|
||||
|
||||
# return original argument if it's not nick-like so special variables and such still work properly
|
||||
return $nick if $nick =~ m/(?:^\$|\s)/;
|
||||
return 0 if $nick =~ m/(?:^\$|\s)/; # not nick-like
|
||||
|
||||
my $percentage = $self->{pbot}->{registry}->get_value('interpreter', 'nick_similarity');
|
||||
$percentage = 0.20 if not defined $percentage;
|
||||
|
Loading…
Reference in New Issue
Block a user