mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Use CSV for GECOS field
This commit is contained in:
parent
c97ba1de20
commit
110c9cc548
@ -21,6 +21,7 @@ use PBot::LagChecker;
|
|||||||
use Time::HiRes qw(gettimeofday tv_interval);
|
use Time::HiRes qw(gettimeofday tv_interval);
|
||||||
use Time::Duration;
|
use Time::Duration;
|
||||||
use POSIX qw/strftime/;
|
use POSIX qw/strftime/;
|
||||||
|
use Text::CSV;
|
||||||
use Carp ();
|
use Carp ();
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -728,6 +729,8 @@ sub check_bans {
|
|||||||
my ($nick) = $mask =~ m/^([^!]+)/;
|
my ($nick) = $mask =~ m/^([^!]+)/;
|
||||||
my %aliases = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($nick);
|
my %aliases = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($nick);
|
||||||
|
|
||||||
|
my $csv = Text::CSV->new;
|
||||||
|
|
||||||
my ($do_not_validate, $bans);
|
my ($do_not_validate, $bans);
|
||||||
foreach my $alias (keys %aliases) {
|
foreach my $alias (keys %aliases) {
|
||||||
next if $alias =~ /^Guest\d+(?:!.*)?$/;
|
next if $alias =~ /^Guest\d+(?:!.*)?$/;
|
||||||
@ -748,7 +751,8 @@ sub check_bans {
|
|||||||
foreach my $nickserv (@nickservs) {
|
foreach my $nickserv (@nickservs) {
|
||||||
my @gecoses;
|
my @gecoses;
|
||||||
if (exists $aliases{$alias}->{gecos}) {
|
if (exists $aliases{$alias}->{gecos}) {
|
||||||
@gecoses = split /,/, $aliases{$alias}->{gecos};
|
$csv->parse($aliases{$alias}->{gecos});
|
||||||
|
@gecoses = $csv->fields;
|
||||||
} else {
|
} else {
|
||||||
@gecoses = (undef);
|
@gecoses = (undef);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use strict;
|
|||||||
use DBI;
|
use DBI;
|
||||||
use Carp qw(shortmess);
|
use Carp qw(shortmess);
|
||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
|
use Text::CSV;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
if(ref($_[1]) eq 'HASH') {
|
if(ref($_[1]) eq 'HASH') {
|
||||||
@ -1168,6 +1169,8 @@ sub get_also_known_as {
|
|||||||
my $nickserv_sth = $self->{dbh}->prepare('SELECT nickserv FROM Nickserv WHERE id = ?');
|
my $nickserv_sth = $self->{dbh}->prepare('SELECT nickserv FROM Nickserv WHERE id = ?');
|
||||||
my $gecos_sth = $self->{dbh}->prepare('SELECT gecos FROM Gecos WHERE id = ?');
|
my $gecos_sth = $self->{dbh}->prepare('SELECT gecos FROM Gecos WHERE id = ?');
|
||||||
|
|
||||||
|
my $csv = Text::CSV->new;
|
||||||
|
|
||||||
foreach my $id (keys %ids) {
|
foreach my $id (keys %ids) {
|
||||||
$hostmask_sth->bind_param(1, $id);
|
$hostmask_sth->bind_param(1, $id);
|
||||||
$hostmask_sth->execute();
|
$hostmask_sth->execute();
|
||||||
@ -1202,9 +1205,15 @@ sub get_also_known_as {
|
|||||||
foreach my $aka (keys %akas) {
|
foreach my $aka (keys %akas) {
|
||||||
if ($akas{$aka}->{id} == $id) {
|
if ($akas{$aka}->{id} == $id) {
|
||||||
if (exists $akas{$aka}->{gecos}) {
|
if (exists $akas{$aka}->{gecos}) {
|
||||||
$akas{$aka}->{gecos} .= ",$row->{gecos}";
|
$csv->parse($akas{$aka}->{gecos});
|
||||||
|
my @gecos = $csv->fields;
|
||||||
|
push @gecos, $row->{gecos};
|
||||||
|
$csv->combine(@gecos);
|
||||||
|
$akas{$aka}->{gecos} = $csv->string;
|
||||||
} else {
|
} else {
|
||||||
$akas{$aka}->{gecos} = $row->{gecos};
|
my @gecos = ($row->{gecos});
|
||||||
|
$csv->combine(@gecos);
|
||||||
|
$akas{$aka}->{gecos} = $csv->string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user