3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 03:02:47 +01:00

Update irccloud detection/handling

This commit is contained in:
Pragmatic Software 2023-01-21 14:47:11 -08:00
parent 576783df55
commit d8803a4c29
4 changed files with 21 additions and 10 deletions

View File

@ -747,7 +747,7 @@ sub check_bans {
{
$banmask = "\$a:$current_nickserv_account";
} else {
if ($host =~ m{^gateway/web/irccloud.com/}) { $banmask = "*!$user\@gateway/web/irccloud.com/*"; }
if ($host =~ m{\.irccloud.com$}) { $banmask = "*!$user\@*.irccloud.com"; }
elsif ($host =~ m{^nat/([^/]+)/}) { $banmask = "*!$user\@nat/$1/*"; }
else {
$banmask = "*!*\@$host";

View File

@ -281,6 +281,13 @@ sub get_baninfo {
[ $self->{pbot}->{registry}->get_value('banlist', 'mute_mode_char'), $self->{quietlist} ],
);
my $is_irccloud = $host =~ m{\.irccloud.com$};
my $irccloud_uid;
if ($is_irccloud) {
($irccloud_uid) = $user =~ /id(\d+)$/;
}
foreach my $entry (@lists) {
my ($mode, $list) = @$entry;
foreach my $banmask ($list->get_keys($channel)) {
@ -298,9 +305,12 @@ sub get_baninfo {
$banned = 1 if defined $nickserv and $nickserv eq $ban_nickserv;
$banned = 1 if $mask =~ m/^$banmask_regex$/i;
if ($banmask =~ m{\@gateway/web/irccloud.com} and $host =~ m{^gateway/web/irccloud.com}) {
# irccloud hosts are disambiguated by the user field which can be uid{N}+ or sid{N}+
# where {N}+ are 1 or more integer digits
if ($is_irccloud && $banmask =~ m{\@.*\.irccloud.com$}) {
my ($bannick, $banuser, $banhost) = $banmask =~ m/([^!]+)!([^@]+)@(.*)/;
$banned = $1 if lc $user eq lc $banuser;
my ($banuid) = $banuser =~ /id(\d+)$/;
$banned = $1 if $irccloud_uid == $banuid;
}
if ($banned) {

View File

@ -307,8 +307,9 @@ sub add_message_account {
my $id;
my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/;
if (defined $link_id and $link_type == $self->{alias_type}->{STRONG}) { $id = $link_id; }
else {
if (defined $link_id and $link_type == $self->{alias_type}->{STRONG}) {
$id = $link_id;
} else {
$id = $self->get_new_account_id();
$self->{pbot}->{logger}->log("Got new account id $id\n");
}
@ -322,7 +323,6 @@ sub add_message_account {
$sth = $self->{dbh}->prepare('INSERT INTO Accounts VALUES (?, ?, ?)');
$sth->execute($id, $mask, "");
$self->{new_entries}++;
$self->{pbot}->{logger}->log("Added new account $id for mask $mask\n");
}
};
@ -602,9 +602,10 @@ sub get_message_account {
return ($rows, 0);
} # end nick-change
if ($host =~ m{^gateway/web/irccloud.com}) {
$sth = $self->{dbh}->prepare('SELECT id, hostmask, last_seen FROM Hostmasks WHERE host = ? ORDER BY last_seen DESC');
$sth->execute("gateway/web/irccloud.com/x-$user");
if ($host =~ m{.*\.irccloud.com$}) {
my ($irccloud_uid) = $user =~ /id(\d+)$/;
$sth = $self->{dbh}->prepare('SELECT id, hostmask, last_seen FROM Hostmasks WHERE host LIKE ? ORDER BY last_seen DESC');
$sth->execute("\%id-${irccloud_uid}\%irccloud.com");
my $rows = $sth->fetchall_arrayref({});
if (defined $rows->[0]) {
$self->{pbot}->{logger}->log("5: irccloud match: $rows->[0]->{id}: $rows->[0]->{hostmask}\n");

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4600,
BUILD_REVISION => 4601,
BUILD_DATE => "2023-01-21",
};