3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

Improve is_present_similiar to accept custom similarity values

This commit is contained in:
Pragmatic Software 2017-05-20 23:44:45 -07:00
parent f5be26a98c
commit 373ebc03b3

View File

@ -121,7 +121,7 @@ sub is_present {
}
sub is_present_similar {
my ($self, $channel, $nick) = @_;
my ($self, $channel, $nick, $similar) = @_;
$channel = lc $channel;
$nick = lc $nick;
@ -139,6 +139,8 @@ sub is_present_similar {
my $percentage = $self->{pbot}->{registry}->get_value('interpreter', 'nick_similarity');
$percentage = 0.20 if not defined $percentage;
$percentage = $similar if defined $similar;
my $now = gettimeofday;
foreach my $person (sort { $self->{nicklist}->{$channel}->{$b}->{timestamp} <=> $self->{nicklist}->{$channel}->{$a}->{timestamp} } keys %{ $self->{nicklist}->{$channel} }) {
return 0 if $now - $self->{nicklist}->{$channel}->{$person}->{timestamp} > 3600; # 1 hour
@ -244,7 +246,7 @@ sub on_nickchange {
sub on_join_channel {
my ($self, $event_type, $event) = @_;
$self->remove_channel($event->{channel}); # clear nicklist to remove any stale nicks before repopulating with namreplies
$self->send_who($event->{channel});
#$self->send_who($event->{channel});
return 0;
}