3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 19:52:34 +01:00

Minor improvement to nick addressing

This commit is contained in:
Pragmatic Software 2017-11-30 13:11:39 -08:00
parent 320c8a4f92
commit 51735494b3
2 changed files with 8 additions and 3 deletions

View File

@ -877,13 +877,16 @@ sub handle_action {
$action = $self->expand_action_arguments($action, $stuff->{arguments}, $stuff->{nick});
}
$stuff->{arguments} = "";
delete $stuff->{nickoverride} unless $stuff->{force_nickoverride};
} else {
if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'text') {
my $target = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{arguments});
if ($target and $action !~ /\$(?:nick|args)\b/) {
$stuff->{nickoverride} = $target;
$stuff->{nickoverride} = $target unless $stuff->{force_nickoverride};
} else {
delete $stuff->{nickoverride} unless $stuff->{force_nickoverride};
}
}
}

View File

@ -230,16 +230,18 @@ sub interpret {
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
if ($similar) {
$stuff->{nickoverride} = $similar;
$stuff->{force_nickoverride} = 1;
} else {
$stuff->{nickoverride} = undef;
delete $stuff->{nickoverride};
}
} elsif ($stuff->{command} =~ /^tell\s+(\p{PosixGraph}{1,20})\s+about\s+(.*)$/is) {
($keyword, $stuff->{nickoverride}) = ($2, $1);
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
if ($similar) {
$stuff->{nickoverride} = $similar;
$stuff->{force_nickoverride} = 1;
} else {
$stuff->{nickoverride} = undef;
delete $stuff->{nickoverride};
}
} elsif ($stuff->{command} =~ /^(.*?)\s+(.*)$/s) {
($keyword, $arguments) = ($1, $2);