mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Support IRCv3 CHGHOST extension
Clean up MessageHistory constants
This commit is contained in:
parent
a173858fb8
commit
d3c8c74a9d
@ -122,14 +122,14 @@ sub check_flood {
|
|||||||
if (defined $id) {
|
if (defined $id) {
|
||||||
if ($id != $account) {
|
if ($id != $account) {
|
||||||
$self->{pbot}->{logger}->log("Linking $mask [$id] to account $account\n");
|
$self->{pbot}->{logger}->log("Linking $mask [$id] to account $account\n");
|
||||||
$self->{pbot}->{messagehistory}->{database}->link_alias($account, $id, $self->{pbot}->{messagehistory}->{database}->{alias_type}->{STRONG}, 1);
|
$self->{pbot}->{messagehistory}->{database}->link_alias($account, $id, LINK_STRONG, 1);
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("New hostmask already belongs to original account.\n");
|
$self->{pbot}->{logger}->log("New hostmask already belongs to original account.\n");
|
||||||
}
|
}
|
||||||
$account = $id;
|
$account = $id;
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("Adding $mask to account $account\n");
|
$self->{pbot}->{logger}->log("Adding $mask to account $account\n");
|
||||||
$self->{pbot}->{messagehistory}->{database}->add_message_account($mask, $account, $self->{pbot}->{messagehistory}->{database}->{alias_type}->{STRONG});
|
$self->{pbot}->{messagehistory}->{database}->add_message_account($mask, $account, LINK_STRONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($account);
|
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($account);
|
||||||
@ -667,7 +667,7 @@ sub check_bans {
|
|||||||
|
|
||||||
$self->{pbot}->{logger}->log("[after aka] processing $alias\n") if $debug_checkban >= 1;
|
$self->{pbot}->{logger}->log("[after aka] processing $alias\n") if $debug_checkban >= 1;
|
||||||
|
|
||||||
if ($aliases{$alias}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK}) {
|
if ($aliases{$alias}->{type} == LINK_WEAK) {
|
||||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] skipping WEAK alias $alias in channel $channel\n") if $debug_checkban >= 2;
|
$self->{pbot}->{logger}->log("anti-flood: [check-bans] skipping WEAK alias $alias in channel $channel\n") if $debug_checkban >= 2;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ use parent 'PBot::Core::Class';
|
|||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
||||||
|
use PBot::Core::MessageHistory::Constants ':all';
|
||||||
|
|
||||||
use Time::HiRes qw/gettimeofday/;
|
use Time::HiRes qw/gettimeofday/;
|
||||||
use Time::Duration;
|
use Time::Duration;
|
||||||
use POSIX qw/strftime/;
|
use POSIX qw/strftime/;
|
||||||
@ -248,7 +250,7 @@ sub get_bans {
|
|||||||
my %akas = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($hostmask);
|
my %akas = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($hostmask);
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
|
|
||||||
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($akas{$aka}->{id});
|
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($akas{$aka}->{id});
|
||||||
|
@ -10,6 +10,8 @@ use parent 'PBot::Core::Class';
|
|||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
||||||
|
use PBot::Core::MessageHistory::Constants ':all';
|
||||||
|
|
||||||
use Time::HiRes qw/gettimeofday/;
|
use Time::HiRes qw/gettimeofday/;
|
||||||
use Time::Duration;
|
use Time::Duration;
|
||||||
use POSIX qw/strftime/;
|
use POSIX qw/strftime/;
|
||||||
@ -120,7 +122,7 @@ sub cmd_unbanme {
|
|||||||
my %aliases = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($context->{nick});
|
my %aliases = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($context->{nick});
|
||||||
|
|
||||||
foreach my $alias (keys %aliases) {
|
foreach my $alias (keys %aliases) {
|
||||||
next if $aliases{$alias}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK};
|
next if $aliases{$alias}->{type} == LINK_WEAK;
|
||||||
next if $aliases{$alias}->{nickchange} == 1;
|
next if $aliases{$alias}->{nickchange} == 1;
|
||||||
|
|
||||||
my $join_flood_channel = $self->{pbot}->{registry}->get_value('antiflood', 'join_flood_channel') // '#stop-join-flood';
|
my $join_flood_channel = $self->{pbot}->{registry}->get_value('antiflood', 'join_flood_channel') // '#stop-join-flood';
|
||||||
|
@ -10,6 +10,8 @@ package PBot::Core::Commands::MessageHistory;
|
|||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
use parent 'PBot::Core::Class';
|
use parent 'PBot::Core::Class';
|
||||||
|
|
||||||
|
use PBot::Core::MessageHistory::Constants ':all';
|
||||||
|
|
||||||
use Time::HiRes qw(time tv_interval);
|
use Time::HiRes qw(time tv_interval);
|
||||||
use Time::Duration;
|
use Time::Duration;
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ sub cmd_list_also_known_as {
|
|||||||
my $sep = "";
|
my $sep = "";
|
||||||
foreach my $aka (sort { $sort{$sort_method}->(\%akas, $sort_direction) } keys %akas) {
|
foreach my $aka (sort { $sort{$sort_method}->(\%akas, $sort_direction) } keys %akas) {
|
||||||
next if $aka =~ /^Guest\d+(?:!.*)?$/;
|
next if $aka =~ /^Guest\d+(?:!.*)?$/;
|
||||||
next if exists $akas{$aka}->{type} and $akas{$aka}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK} && not $show_weak;
|
next if exists $akas{$aka}->{type} and $akas{$aka}->{type} == LINK_WEAK && not $show_weak;
|
||||||
|
|
||||||
if (not $show_hostmasks) {
|
if (not $show_hostmasks) {
|
||||||
my ($nick) = $aka =~ m/([^!]+)/;
|
my ($nick) = $aka =~ m/([^!]+)/;
|
||||||
@ -178,7 +180,7 @@ sub cmd_list_also_known_as {
|
|||||||
$result .= " [$akas{$aka}->{id}]";
|
$result .= " [$akas{$aka}->{id}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= " [WEAK]" if exists $akas{$aka}->{type} and $akas{$aka}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK};
|
$result .= " [WEAK]" if exists $akas{$aka}->{type} and $akas{$aka}->{type} == LINK_WEAK;
|
||||||
|
|
||||||
if ($show_last_seen) {
|
if ($show_last_seen) {
|
||||||
my $seen = concise ago (time - $akas{$aka}->{last_seen});
|
my $seen = concise ago (time - $akas{$aka}->{last_seen});
|
||||||
@ -474,7 +476,7 @@ sub cmd_aka_link {
|
|||||||
|
|
||||||
my ($id, $alias, $type) = split /\s+/, $context->{arguments};
|
my ($id, $alias, $type) = split /\s+/, $context->{arguments};
|
||||||
|
|
||||||
$type = $self->{pbot}->{messagehistory}->{database}->{alias_type}->{STRONG} if not defined $type;
|
$type = LINK_STRONG if not defined $type;
|
||||||
|
|
||||||
if (not $id or not $alias) {
|
if (not $id or not $alias) {
|
||||||
return "Usage: akalink <target id> <alias id> [type]";
|
return "Usage: akalink <target id> <alias id> [type]";
|
||||||
@ -492,7 +494,7 @@ sub cmd_aka_link {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($self->{pbot}->{messagehistory}->{database}->link_alias($id, $alias, $type)) {
|
if ($self->{pbot}->{messagehistory}->{database}->link_alias($id, $alias, $type)) {
|
||||||
return "/say $source " . ($type == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK} ? "weakly" : "strongly") . " linked to $target.";
|
return "/say $source " . ($type == LINK_WEAK ? "weakly" : "strongly") . " linked to $target.";
|
||||||
} else {
|
} else {
|
||||||
return "Link failed.";
|
return "Link failed.";
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ sub request_caps {
|
|||||||
my %desired_caps = (
|
my %desired_caps = (
|
||||||
'account-notify' => 1,
|
'account-notify' => 1,
|
||||||
'account-tag' => 1,
|
'account-tag' => 1,
|
||||||
|
'chghost' => 1,
|
||||||
'extended-join' => 1,
|
'extended-join' => 1,
|
||||||
'message-tags' => 1,
|
'message-tags' => 1,
|
||||||
'multi-prefix' => 1,
|
'multi-prefix' => 1,
|
||||||
@ -102,7 +103,6 @@ sub request_caps {
|
|||||||
|
|
||||||
# TODO: unsupported capabilities worth looking into
|
# TODO: unsupported capabilities worth looking into
|
||||||
'away-notify' => 0,
|
'away-notify' => 0,
|
||||||
'chghost' => 0,
|
|
||||||
'identify-msg' => 0,
|
'identify-msg' => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ sub initialize {
|
|||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.n_local', sub { $self->log_third_arg (@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.n_local', sub { $self->log_third_arg (@_) });
|
||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.n_global', sub { $self->log_third_arg (@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.n_global', sub { $self->log_third_arg (@_) });
|
||||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.nononreg', sub { $self->on_nononreg (@_) });
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.nononreg', sub { $self->on_nononreg (@_) });
|
||||||
|
$self->{pbot}->{event_dispatcher}->register_handler('irc.chghost', sub { $self->on_chghost (@_) });
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_init {
|
sub on_init {
|
||||||
@ -176,6 +177,35 @@ sub on_nononreg {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub on_chghost {
|
||||||
|
my ($self, $event_type, $event) = @_;
|
||||||
|
|
||||||
|
my $nick = $event->nick;
|
||||||
|
my $user = $event->user;
|
||||||
|
my $host = $event->host;
|
||||||
|
my $newuser = $event->{args}[0];
|
||||||
|
my $newhost = $event->{args}[1];
|
||||||
|
|
||||||
|
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
|
||||||
|
($nick, $newuser, $newhost) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $newuser, $newhost);
|
||||||
|
|
||||||
|
my $account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host);
|
||||||
|
|
||||||
|
$self->{pbot}->{logger}->log("[CHGHOST] ($account) $nick!$user\@$host changed host to $nick!$newuser\@$newhost\n");
|
||||||
|
|
||||||
|
my $id = $self->{pbot}->{messagehistory}->{database}->get_message_account_id("$nick!$newuser\@$newhost");
|
||||||
|
|
||||||
|
if (defined $id) {
|
||||||
|
if ($id != $account) {
|
||||||
|
$self->{pbot}->{messagehistory}->{database}->link_alias($account, $id, LINK_STRONG);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$self->{pbot}->{messagehistory}->{database}->add_message_account("$nick!$newuser\@$newhost", $account, LINK_STRONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sub log_first_arg {
|
sub log_first_arg {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
$self->{pbot}->{logger}->log("$event->{args}[1]\n");
|
$self->{pbot}->{logger}->log("$event->{args}[1]\n");
|
||||||
|
@ -1007,7 +1007,6 @@ sub parse {
|
|||||||
or $type eq "topic"
|
or $type eq "topic"
|
||||||
or $type eq "invite"
|
or $type eq "invite"
|
||||||
or $type eq "whoisaccount"
|
or $type eq "whoisaccount"
|
||||||
or $type eq "chghost"
|
|
||||||
or $type eq "cap") # IRCv3 client capabilities pragma-
|
or $type eq "cap") # IRCv3 client capabilities pragma-
|
||||||
{
|
{
|
||||||
$ev = PBot::Core::IRC::Event->new(
|
$ev = PBot::Core::IRC::Event->new(
|
||||||
@ -1017,7 +1016,10 @@ sub parse {
|
|||||||
$type,
|
$type,
|
||||||
@stuff,
|
@stuff,
|
||||||
);
|
);
|
||||||
} elsif ($type eq "quit" or $type eq "nick" or $type eq "account") {
|
} elsif ($type eq "quit"
|
||||||
|
or $type eq "nick"
|
||||||
|
or $type eq "account"
|
||||||
|
or $type eq "chghost") {
|
||||||
$ev = PBot::Core::IRC::Event->new(
|
$ev = PBot::Core::IRC::Event->new(
|
||||||
$type, # pragma_ 2011/21/01
|
$type, # pragma_ 2011/21/01
|
||||||
$from,
|
$from,
|
||||||
|
@ -4,23 +4,24 @@
|
|||||||
|
|
||||||
package PBot::Core::MessageHistory::Constants;
|
package PBot::Core::MessageHistory::Constants;
|
||||||
|
|
||||||
use Exporter qw/import/;
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
use constant;
|
||||||
|
|
||||||
our @EXPORT = ();
|
my %constants = (
|
||||||
|
|
||||||
our %EXPORT_TAGS = (
|
|
||||||
'all' => [qw/MSG_CHAT MSG_JOIN MSG_DEPARTURE MSG_NICKCHANGE/],
|
|
||||||
);
|
|
||||||
|
|
||||||
our @EXPORT_OK = (
|
|
||||||
@{ $EXPORT_TAGS{all} },
|
|
||||||
);
|
|
||||||
|
|
||||||
use constant {
|
|
||||||
MSG_CHAT => 0, # PRIVMSG, ACTION
|
MSG_CHAT => 0, # PRIVMSG, ACTION
|
||||||
MSG_JOIN => 1, # JOIN
|
MSG_JOIN => 1, # JOIN
|
||||||
MSG_DEPARTURE => 2, # PART, QUIT, KICK
|
MSG_DEPARTURE => 2, # PART, QUIT, KICK
|
||||||
MSG_NICKCHANGE => 3, # CHANGED NICK
|
MSG_NICKCHANGE => 3, # CHANGED NICK
|
||||||
};
|
|
||||||
|
LINK_WEAK => 0, # weakly linked AKAs
|
||||||
|
LINK_STRONG => 1, # strongly linked AKAs
|
||||||
|
);
|
||||||
|
|
||||||
|
constant->import(\%constants);
|
||||||
|
|
||||||
|
use Exporter qw/import/;
|
||||||
|
our %EXPORT_TAGS = ('all' => [keys %constants]);
|
||||||
|
our @EXPORT_OK = (@{$EXPORT_TAGS{all}});
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -47,9 +47,6 @@ sub initialize {
|
|||||||
sub { $self->commit_message_history },
|
sub { $self->commit_message_history },
|
||||||
$self->{pbot}->{registry}->get_value('messagehistory', 'sqlite_commit_interval'),
|
$self->{pbot}->{registry}->get_value('messagehistory', 'sqlite_commit_interval'),
|
||||||
'messagehistory commit');
|
'messagehistory commit');
|
||||||
|
|
||||||
$self->{alias_type}->{WEAK} = 0;
|
|
||||||
$self->{alias_type}->{STRONG} = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub sqlite_commit_interval_trigger {
|
sub sqlite_commit_interval_trigger {
|
||||||
@ -309,7 +306,7 @@ sub add_message_account {
|
|||||||
my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/;
|
my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/;
|
||||||
my $id;
|
my $id;
|
||||||
|
|
||||||
if (defined $link_id and $link_type == $self->{alias_type}->{STRONG}) {
|
if (defined $link_id and $link_type == LINK_STRONG) {
|
||||||
$self->{pbot}->{logger}->log("[MH] Using Account id $link_id for $mask due to strong link\n");
|
$self->{pbot}->{logger}->log("[MH] Using Account id $link_id for $mask due to strong link\n");
|
||||||
$id = $link_id;
|
$id = $link_id;
|
||||||
} else {
|
} else {
|
||||||
@ -324,7 +321,7 @@ sub add_message_account {
|
|||||||
|
|
||||||
#$self->{pbot}->{logger}->log("[MH] Added new Hostmask entry $mask for message account $id\n");
|
#$self->{pbot}->{logger}->log("[MH] Added new Hostmask entry $mask for message account $id\n");
|
||||||
|
|
||||||
if ((not defined $link_id) || ((defined $link_id) && ($link_type == $self->{alias_type}->{WEAK}))) {
|
if ((not defined $link_id) || ((defined $link_id) && ($link_type == LINK_WEAK))) {
|
||||||
$sth = $self->{dbh}->prepare('INSERT INTO Accounts VALUES (?, ?, ?)');
|
$sth = $self->{dbh}->prepare('INSERT INTO Accounts VALUES (?, ?, ?)');
|
||||||
$sth->execute($id, $mask, "");
|
$sth->execute($id, $mask, "");
|
||||||
$self->{new_entries}++;
|
$self->{new_entries}++;
|
||||||
@ -334,7 +331,7 @@ sub add_message_account {
|
|||||||
|
|
||||||
$self->{pbot}->{logger}->log("EXCEPT: $@\n") if $@;
|
$self->{pbot}->{logger}->log("EXCEPT: $@\n") if $@;
|
||||||
|
|
||||||
if (defined $link_id && $link_type == $self->{alias_type}->{WEAK}) {
|
if (defined $link_id && $link_type == LINK_WEAK) {
|
||||||
$self->{pbot}->{logger}->log("[MH] Weakly linking $id to $link_id\n");
|
$self->{pbot}->{logger}->log("[MH] Weakly linking $id to $link_id\n");
|
||||||
$self->link_alias($id, $link_id, $link_type);
|
$self->link_alias($id, $link_id, $link_type);
|
||||||
}
|
}
|
||||||
@ -458,12 +455,12 @@ sub get_message_account {
|
|||||||
|
|
||||||
# found a probable match
|
# found a probable match
|
||||||
if (defined $rows->[0]) {
|
if (defined $rows->[0]) {
|
||||||
my $link_type = $self->{alias_type}->{STRONG};
|
my $link_type = LINK_STRONG;
|
||||||
|
|
||||||
# if 48 hours have elapsed since this *!user@host was seen
|
# if 48 hours have elapsed since this *!user@host was seen
|
||||||
# then still link the Guest to this account, but weakly
|
# then still link the Guest to this account, but weakly
|
||||||
if (time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
if (time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
||||||
$link_type = $self->{alias_type}->{WEAK};
|
$link_type = LINK_WEAK;
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log(
|
$self->{pbot}->{logger}->log(
|
||||||
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ")"
|
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ")"
|
||||||
@ -487,7 +484,7 @@ sub get_message_account {
|
|||||||
if (not defined $rows->[0]) {
|
if (not defined $rows->[0]) {
|
||||||
$rows->[0] = { id => $orig_id, hostmask => "$orig_nick!$user\@$host" };
|
$rows->[0] = { id => $orig_id, hostmask => "$orig_nick!$user\@$host" };
|
||||||
$orig_nick = undef; # nick-change handled
|
$orig_nick = undef; # nick-change handled
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
# look up original nick's NickServ accounts outside of upcoming loop
|
# look up original nick's NickServ accounts outside of upcoming loop
|
||||||
@ -511,7 +508,7 @@ sub get_message_account {
|
|||||||
# check each aka for identifying details
|
# check each aka for identifying details
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
# skip dubious links
|
# skip dubious links
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
|
|
||||||
# don't process duplicates
|
# don't process duplicates
|
||||||
@ -557,7 +554,7 @@ sub get_message_account {
|
|||||||
id => $self->get_ancestor_id($akas{$aka}->{id}),
|
id => $self->get_ancestor_id($akas{$aka}->{id}),
|
||||||
hostmask => $aka,
|
hostmask => $aka,
|
||||||
};
|
};
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +588,7 @@ sub get_message_account {
|
|||||||
if ($match) {
|
if ($match) {
|
||||||
$self->{pbot}->{logger}->log("[MH] Using this match.\n");
|
$self->{pbot}->{logger}->log("[MH] Using this match.\n");
|
||||||
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,7 +596,7 @@ sub get_message_account {
|
|||||||
$self->{pbot}->{logger}->log("[MH] Creating new nickchange account!\n");
|
$self->{pbot}->{logger}->log("[MH] Creating new nickchange account!\n");
|
||||||
|
|
||||||
my $new_id = $self->add_message_account($mask);
|
my $new_id = $self->add_message_account($mask);
|
||||||
$self->link_alias($orig_id, $new_id, $self->{alias_type}->{WEAK});
|
$self->link_alias($orig_id, $new_id, LINK_WEAK);
|
||||||
$self->update_hostmask_data($mask, {nickchange => 1, last_seen => scalar time});
|
$self->update_hostmask_data($mask, {nickchange => 1, last_seen => scalar time});
|
||||||
|
|
||||||
$do_nothing = 1;
|
$do_nothing = 1;
|
||||||
@ -614,7 +611,7 @@ sub get_message_account {
|
|||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
if (defined $rows->[0]) {
|
if (defined $rows->[0]) {
|
||||||
$self->{pbot}->{logger}->log("[MH] 5: irccloud match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
$self->{pbot}->{logger}->log("[MH] 5: irccloud match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,7 +622,7 @@ sub get_message_account {
|
|||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
if (defined $rows->[0]) {
|
if (defined $rows->[0]) {
|
||||||
$self->{pbot}->{logger}->log("[MH] 6: nat match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
$self->{pbot}->{logger}->log("[MH] 6: nat match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +633,7 @@ sub get_message_account {
|
|||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
if (defined $rows->[0]) {
|
if (defined $rows->[0]) {
|
||||||
$self->{pbot}->{logger}->log("[MH] 6: cloak match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
$self->{pbot}->{logger}->log("[MH] 6: cloak match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,9 +643,9 @@ sub get_message_account {
|
|||||||
$sth->execute($user, $host);
|
$sth->execute($user, $host);
|
||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
if (defined $rows->[0]) {
|
if (defined $rows->[0]) {
|
||||||
my $link_type = $self->{alias_type}->{STRONG};
|
my $link_type = LINK_STRONG;
|
||||||
if (time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
if (time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
||||||
$link_type = $self->{alias_type}->{WEAK};
|
$link_type = LINK_WEAK;
|
||||||
$self->{pbot}->{logger}->log(
|
$self->{pbot}->{logger}->log(
|
||||||
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ") for $rows->[0]->{hostmask} for $nick!$user\@$host, degrading to weak link\n");
|
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ") for $rows->[0]->{hostmask} for $nick!$user\@$host, degrading to weak link\n");
|
||||||
}
|
}
|
||||||
@ -661,7 +658,7 @@ sub get_message_account {
|
|||||||
$sth->execute($nick);
|
$sth->execute($nick);
|
||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
|
|
||||||
my $link_type = $self->{alias_type}->{WEAK};
|
my $link_type = LINK_WEAK;
|
||||||
my %processed_nicks;
|
my %processed_nicks;
|
||||||
my %processed_akas;
|
my %processed_akas;
|
||||||
|
|
||||||
@ -674,7 +671,7 @@ sub get_message_account {
|
|||||||
|
|
||||||
my %akas = $self->get_also_known_as($tnick);
|
my %akas = $self->get_also_known_as($tnick);
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
|
|
||||||
next if exists $processed_akas{$akas{$aka}->{id}};
|
next if exists $processed_akas{$akas{$aka}->{id}};
|
||||||
@ -693,7 +690,7 @@ sub get_message_account {
|
|||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("[MH] Cloaked hosts match: $host vs $thost\n");
|
$self->{pbot}->{logger}->log("[MH] Cloaked hosts match: $host vs $thost\n");
|
||||||
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,20 +723,20 @@ sub get_message_account {
|
|||||||
|
|
||||||
if ($match) {
|
if ($match) {
|
||||||
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
$rows->[0] = {id => $self->get_ancestor_id($akas{$aka}->{id}), hostmask => $aka};
|
||||||
return ($rows, $self->{alias_type}->{STRONG});
|
return ($rows, LINK_STRONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not defined $rows->[0]) {
|
if (not defined $rows->[0]) {
|
||||||
$link_type = $self->{alias_type}->{STRONG};
|
$link_type = LINK_STRONG;
|
||||||
|
|
||||||
$sth = $self->{dbh}->prepare('SELECT id, hostmask, last_seen FROM Hostmasks WHERE user = ? AND host = ? ORDER BY last_seen DESC');
|
$sth = $self->{dbh}->prepare('SELECT id, hostmask, last_seen FROM Hostmasks WHERE user = ? AND host = ? ORDER BY last_seen DESC');
|
||||||
$sth->execute($user, $host);
|
$sth->execute($user, $host);
|
||||||
$rows = $sth->fetchall_arrayref({});
|
$rows = $sth->fetchall_arrayref({});
|
||||||
|
|
||||||
if (defined $rows->[0] and time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
if (defined $rows->[0] and time - $rows->[0]->{last_seen} > 60 * 60 * 48) {
|
||||||
$link_type = $self->{alias_type}->{WEAK};
|
$link_type = LINK_WEAK;
|
||||||
$self->{pbot}->{logger}->log(
|
$self->{pbot}->{logger}->log(
|
||||||
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ") for $rows->[0]->{hostmask} for $nick!$user\@$host, degrading to weak link\n");
|
"[MH] Longer than 48 hours (" . concise duration(time - $rows->[0]->{last_seen}) . ") for $rows->[0]->{hostmask} for $nick!$user\@$host, degrading to weak link\n");
|
||||||
}
|
}
|
||||||
@ -766,7 +763,7 @@ sub get_message_account {
|
|||||||
return $rows->[0]->{id} if $do_nothing;
|
return $rows->[0]->{id} if $do_nothing;
|
||||||
|
|
||||||
if (defined $rows->[0] and not defined $orig_nick) {
|
if (defined $rows->[0] and not defined $orig_nick) {
|
||||||
if ($link_type == $self->{alias_type}->{STRONG}) {
|
if ($link_type == LINK_STRONG) {
|
||||||
my $host1 = lc "$nick!$user\@$host";
|
my $host1 = lc "$nick!$user\@$host";
|
||||||
my $host2 = lc $rows->[0]->{hostmask};
|
my $host2 = lc $rows->[0]->{hostmask};
|
||||||
|
|
||||||
@ -789,7 +786,7 @@ sub get_message_account {
|
|||||||
my $hostmask = $rows->[0]->{hostmask};
|
my $hostmask = $rows->[0]->{hostmask};
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("[MH] message-history: [get-account] $mask "
|
$self->{pbot}->{logger}->log("[MH] message-history: [get-account] $mask "
|
||||||
. ($link_type == $self->{alias_type}->{WEAK} ? "weakly linked to" : "added to account")
|
. ($link_type == LINK_WEAK ? "weakly linked to" : "added to account")
|
||||||
. " $hostmask with id $id\n"
|
. " $hostmask with id $id\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -931,13 +928,13 @@ sub get_recent_messages {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$id} = {
|
$akas{$id} = {
|
||||||
id => $id,
|
id => $id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1002,13 +999,13 @@ sub get_message_context {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$context_id} = {
|
$akas{$context_id} = {
|
||||||
id => $context_id,
|
id => $context_id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1098,13 +1095,13 @@ sub recall_message_by_count {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$id} = {
|
$akas{$id} = {
|
||||||
id => $id,
|
id => $id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1164,13 +1161,13 @@ sub recall_message_by_text {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$id} = {
|
$akas{$id} = {
|
||||||
id => $id,
|
id => $id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1231,13 +1228,13 @@ sub get_random_message {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$id} = {
|
$akas{$id} = {
|
||||||
id => $id,
|
id => $id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1282,7 +1279,7 @@ sub get_max_messages {
|
|||||||
} else {
|
} else {
|
||||||
$akas{$id} = {
|
$akas{$id} = {
|
||||||
id => $id,
|
id => $id,
|
||||||
type => $self->{alias_type}->{STRONG},
|
type => LINK_STRONG,
|
||||||
nickchange => 0,
|
nickchange => 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1290,7 +1287,7 @@ sub get_max_messages {
|
|||||||
my %seen_id;
|
my %seen_id;
|
||||||
|
|
||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
next if $akas{$aka}->{type} == $self->{alias_type}->{WEAK};
|
next if $akas{$aka}->{type} == LINK_WEAK;
|
||||||
next if $akas{$aka}->{nickchange} == 1;
|
next if $akas{$aka}->{nickchange} == 1;
|
||||||
next if exists $seen_id{$akas{$aka}->{id}};
|
next if exists $seen_id{$akas{$aka}->{id}};
|
||||||
|
|
||||||
@ -1470,10 +1467,10 @@ sub link_aliases {
|
|||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
my $idhost = $self->find_most_recent_hostmask($row->{id}) if $debug_link >= 2 && $row->{id} != $account;
|
my $idhost = $self->find_most_recent_hostmask($row->{id}) if $debug_link >= 2 && $row->{id} != $account;
|
||||||
if ($now - $row->{last_seen} <= 60 * 60 * 48) {
|
if ($now - $row->{last_seen} <= 60 * 60 * 48) {
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}, force => 1};
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG, force => 1};
|
||||||
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($idhost) for host [$host]\n") if $debug_link >= 2 && $row->{id} != $account;
|
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($idhost) for host [$host]\n") if $debug_link >= 2 && $row->{id} != $account;
|
||||||
} else {
|
} else {
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{WEAK}};
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_WEAK};
|
||||||
$self->{pbot}->{logger}->log("found WEAK matching id $row->{id} ($idhost) for host [$host]\n") if $debug_link >= 2 && $row->{id} != $account;
|
$self->{pbot}->{logger}->log("found WEAK matching id $row->{id} ($idhost) for host [$host]\n") if $debug_link >= 2 && $row->{id} != $account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1505,7 +1502,7 @@ sub link_aliases {
|
|||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("Cloaked hosts match: $host vs $thost\n");
|
$self->{pbot}->{logger}->log("Cloaked hosts match: $host vs $thost\n");
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}, force => 1};
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG, force => 1};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,20 +1513,20 @@ sub link_aliases {
|
|||||||
|
|
||||||
if ($length != 0 && $distance / $length < 0.50) {
|
if ($length != 0 && $distance / $length < 0.50) {
|
||||||
$self->{pbot}->{logger}->log("11: distance match: $host vs $thost == " . ($distance / $length) . "\n");
|
$self->{pbot}->{logger}->log("11: distance match: $host vs $thost == " . ($distance / $length) . "\n");
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}}; # don't force linking
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG}; # don't force linking
|
||||||
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($row->{hostmask}) for nick [$nick]\n") if $debug_link >= 2;
|
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($row->{hostmask}) for nick [$nick]\n") if $debug_link >= 2;
|
||||||
} else {
|
} else {
|
||||||
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
|
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
|
||||||
if (defined $hostip) {
|
if (defined $hostip) {
|
||||||
if ($hostip eq $thost) {
|
if ($hostip eq $thost) {
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}}; # don't force linking
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG}; # don't force linking
|
||||||
$self->{pbot}->{logger}->log("IP vs hostname match: $host vs $thost\n");
|
$self->{pbot}->{logger}->log("IP vs hostname match: $host vs $thost\n");
|
||||||
}
|
}
|
||||||
} elsif ($thost =~ m/(\d+[[:punct:]]\d+[[:punct:]]\d+[[:punct:]]\d+)\D/) {
|
} elsif ($thost =~ m/(\d+[[:punct:]]\d+[[:punct:]]\d+[[:punct:]]\d+)\D/) {
|
||||||
my $thostip = $1;
|
my $thostip = $1;
|
||||||
$thostip =~ s/[[:punct:]]/./g;
|
$thostip =~ s/[[:punct:]]/./g;
|
||||||
if ($thostip eq $host) {
|
if ($thostip eq $host) {
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}}; # don't force linking
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG}; # don't force linking
|
||||||
$self->{pbot}->{logger}->log("IP vs hostname match: $host vs $thost\n");
|
$self->{pbot}->{logger}->log("IP vs hostname match: $host vs $thost\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1545,7 +1542,7 @@ sub link_aliases {
|
|||||||
|
|
||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
my $idhost = $self->find_most_recent_hostmask($row->{id}) if $debug_link >= 2 && $row->{id} != $account;
|
my $idhost = $self->find_most_recent_hostmask($row->{id}) if $debug_link >= 2 && $row->{id} != $account;
|
||||||
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}, force => 1};
|
$ids{$row->{id}} = {id => $row->{id}, type => LINK_STRONG, force => 1};
|
||||||
$self->{pbot}->{logger}->log("12: found STRONG matching id $row->{id} ($idhost) for nickserv [$nickserv]\n") if $debug_link >= 2 && $row->{id} != $account;
|
$self->{pbot}->{logger}->log("12: found STRONG matching id $row->{id} ($idhost) for nickserv [$nickserv]\n") if $debug_link >= 2 && $row->{id} != $account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1564,7 +1561,7 @@ sub link_alias {
|
|||||||
my $debug_link = $self->{pbot}->{registry}->get_value('messagehistory', 'debug_link');
|
my $debug_link = $self->{pbot}->{registry}->get_value('messagehistory', 'debug_link');
|
||||||
|
|
||||||
$self->{pbot}->{logger}
|
$self->{pbot}->{logger}
|
||||||
->log("Attempting to " . ($force ? "forcefully " : "") . ($type == $self->{alias_type}->{STRONG} ? "strongly" : "weakly") . " link $id to $alias\n")
|
->log("Attempting to " . ($force ? "forcefully " : "") . ($type == LINK_STRONG ? "strongly" : "weakly") . " link $id to $alias\n")
|
||||||
if $debug_link >= 3;
|
if $debug_link >= 3;
|
||||||
|
|
||||||
my $ret = eval {
|
my $ret = eval {
|
||||||
@ -1576,7 +1573,7 @@ sub link_alias {
|
|||||||
if (defined $row) {
|
if (defined $row) {
|
||||||
if ($force) {
|
if ($force) {
|
||||||
if ($row->{'type'} != $type) {
|
if ($row->{'type'} != $type) {
|
||||||
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == $self->{alias_type}->{STRONG} ? "strongly" : "weakly") . " linked to $alias, forcing override\n")
|
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == LINK_STRONG ? "strongly" : "weakly") . " linked to $alias, forcing override\n")
|
||||||
if $debug_link >= 1;
|
if $debug_link >= 1;
|
||||||
|
|
||||||
$sth = $self->{dbh}->prepare('UPDATE Aliases SET type = ? WHERE alias = ? AND id = ?');
|
$sth = $self->{dbh}->prepare('UPDATE Aliases SET type = ? WHERE alias = ? AND id = ?');
|
||||||
@ -1584,12 +1581,12 @@ sub link_alias {
|
|||||||
$sth->execute($type, $alias, $id);
|
$sth->execute($type, $alias, $id);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == $self->{alias_type}->{STRONG} ? "strongly" : "weakly") . " linked to $alias, ignoring\n")
|
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == LINK_STRONG ? "strongly" : "weakly") . " linked to $alias, ignoring\n")
|
||||||
if $debug_link >= 4;
|
if $debug_link >= 4;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == $self->{alias_type}->{STRONG} ? "strongly" : "weakly") . " linked to $alias, ignoring\n")
|
$self->{pbot}->{logger}->log("$id already " . ($row->{'type'} == LINK_STRONG ? "strongly" : "weakly") . " linked to $alias, ignoring\n")
|
||||||
if $debug_link >= 4;
|
if $debug_link >= 4;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1605,7 +1602,7 @@ sub link_alias {
|
|||||||
my $host1 = $self->find_most_recent_hostmask($id);
|
my $host1 = $self->find_most_recent_hostmask($id);
|
||||||
my $host2 = $self->find_most_recent_hostmask($alias);
|
my $host2 = $self->find_most_recent_hostmask($alias);
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log(($type == $self->{alias_type}->{STRONG} ? "Strongly" : "Weakly") . " linked $id ($host1) to $alias ($host2).\n") if $ret and $debug_link;
|
$self->{pbot}->{logger}->log(($type == LINK_STRONG ? "Strongly" : "Weakly") . " linked $id ($host1) to $alias ($host2).\n") if $ret and $debug_link;
|
||||||
|
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
$host1 = lc $host1;
|
$host1 = lc $host1;
|
||||||
@ -1754,7 +1751,7 @@ sub get_also_known_as {
|
|||||||
|
|
||||||
if (not defined $id) { return %akas; }
|
if (not defined $id) { return %akas; }
|
||||||
|
|
||||||
$ids{$id} = {id => $id, type => $self->{alias_type}->{STRONG}};
|
$ids{$id} = {id => $id, type => LINK_STRONG};
|
||||||
$self->{pbot}->{logger}->log("Adding $id -> $id\n") if $debug > 2;
|
$self->{pbot}->{logger}->log("Adding $id -> $id\n") if $debug > 2;
|
||||||
|
|
||||||
my $sth = $self->{dbh}->prepare('SELECT alias, type FROM Aliases WHERE id = ?');
|
my $sth = $self->{dbh}->prepare('SELECT alias, type FROM Aliases WHERE id = ?');
|
||||||
@ -1762,7 +1759,7 @@ sub get_also_known_as {
|
|||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
|
|
||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
# next if $row->{type} == $self->{alias_type}->{WEAK};
|
# next if $row->{type} == LINK_WEAK;
|
||||||
$ids{$row->{alias}} = {id => $id, type => $row->{type}};
|
$ids{$row->{alias}} = {id => $id, type => $row->{type}};
|
||||||
$self->{pbot}->{logger}->log("[$id] 1) Adding $row->{alias} -> $id [type $row->{type}]\n") if $debug > 2;
|
$self->{pbot}->{logger}->log("[$id] 1) Adding $row->{alias} -> $id [type $row->{type}]\n") if $debug > 2;
|
||||||
}
|
}
|
||||||
@ -1773,7 +1770,7 @@ sub get_also_known_as {
|
|||||||
while (1) {
|
while (1) {
|
||||||
my $new_aliases = 0;
|
my $new_aliases = 0;
|
||||||
foreach my $id (keys %ids) {
|
foreach my $id (keys %ids) {
|
||||||
next if $ids{$id}->{type} == $self->{alias_type}->{WEAK};
|
next if $ids{$id}->{type} == LINK_WEAK;
|
||||||
next if exists $seen_id{$id};
|
next if exists $seen_id{$id};
|
||||||
$seen_id{$id} = $id;
|
$seen_id{$id} = $id;
|
||||||
|
|
||||||
@ -1783,8 +1780,8 @@ sub get_also_known_as {
|
|||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
next if exists $ids{$row->{id}};
|
next if exists $ids{$row->{id}};
|
||||||
|
|
||||||
#next if $row->{type} == $self->{alias_type}->{WEAK};
|
#next if $row->{type} == LINK_WEAK;
|
||||||
$ids{$row->{id}} = {id => $id, type => $ids{$id}->{type} == $self->{alias_type}->{WEAK} ? $self->{alias_type}->{WEAK} : $row->{type}};
|
$ids{$row->{id}} = {id => $id, type => $ids{$id}->{type} == LINK_WEAK ? LINK_WEAK : $row->{type}};
|
||||||
$new_aliases++;
|
$new_aliases++;
|
||||||
$self->{pbot}->{logger}->log("[$id] 2) Adding $row->{id} -> $id [type $row->{type}]\n") if $debug > 2;
|
$self->{pbot}->{logger}->log("[$id] 2) Adding $row->{id} -> $id [type $row->{type}]\n") if $debug > 2;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4611,
|
BUILD_REVISION => 4612,
|
||||||
BUILD_DATE => "2023-02-01",
|
BUILD_DATE => "2023-02-01",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user