mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 00:45:43 -04:00
fix pbadmin to use new db, setup new channel default for eval
This commit is contained in:
parent
d9fb5aa94e
commit
2b6d8942ba
2 changed files with 18 additions and 13 deletions
|
@ -22,11 +22,12 @@ sub dbh {
|
|||
return $self->{$env . "dbh"};
|
||||
}
|
||||
|
||||
if ($env =~ /^www|dev$/) {
|
||||
$self->{$env . "dbh"} = DBI->connect( "dbi:SQLite:dbname=/var/www/domains/perl.bot/".$env."/pastes.db", "", "", { PrintError => 0, RaiseError => 1 } );
|
||||
} elsif ($env eq 'asn') {
|
||||
$self->{$env . "dbh"} = DBI->connect( "dbi:SQLite:dbname=var/asn.db", "", "", { PrintError => 0, RaiseError => 1 } );
|
||||
}
|
||||
my $dbnames = {
|
||||
www => "perlbot_pastes",
|
||||
dev => "perlbot_pastes_dev",
|
||||
};
|
||||
|
||||
$self->{$env . "dbh"} = DBI->connect( "dbi:Pg:dbname=".$dbnames->{$env}, "perlbot_pastebin", "ignored", { PrintError => 2, RaiseError => 1 } );
|
||||
|
||||
return $self->{$env."dbh"};
|
||||
}
|
||||
|
@ -35,7 +36,6 @@ sub postload {
|
|||
|
||||
delete $self->{wwwdbh}; # UGLY HAX GO.
|
||||
delete $self->{devdbh};
|
||||
delete $self->{asndbh};
|
||||
# Basically we delete the dbh we cached so we don't fork
|
||||
# with one active
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ sub postload {
|
|||
sub add_ban_word {
|
||||
my ($self, $env, $who, $where, $word) = @_;
|
||||
|
||||
$self->dbh($env)->do("INSERT INTO banned_words (word, who, 'where') VALUES (?, ?, ?)", {}, $word, $who, $where);
|
||||
$self->dbh($env)->do(q{INSERT INTO banned_words (word, who, "where") VALUES (?, ?, ?)}, {}, $word, $who, $where);
|
||||
}
|
||||
|
||||
sub get_ip_for_paste {
|
||||
my ($self, $env, $id) = @_;
|
||||
|
||||
my ($ip) = @{$self->dbh($env)->selectrow_arrayref("SELECT ip FROM posts p JOIN slugs s ON s.post_id = p.id WHERE s.slug = ? or p.id = ?", {}, $id, $id) || ['0.0.0.0']};
|
||||
my ($ip) = @{$self->dbh($env)->selectrow_arrayref("SELECT ip FROM posts p JOIN slugs s ON s.post_id = p.id WHERE s.slug = ?", {}, $id) || ['0.0.0.0']};
|
||||
|
||||
return sprintf("%03d.%03d.%03d.%03d", split(/\./,$ip));
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ sub get_asn_for_paste {
|
|||
|
||||
my $ip = $self->get_ip_for_paste($env, $id);
|
||||
|
||||
my ($asn) = @{$self->dbh('asn')->selectrow_arrayref("SELECT asn FROM asn WHERE ? >= start AND ? <= end", {}, $ip, $ip) || []}[0];
|
||||
my ($asn) = @{$self->dbh('www')->selectrow_arrayref('SELECT asn FROM asn WHERE ? >= start AND ? <= "end"', {}, $ip, $ip) || []}[0];
|
||||
return $asn;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ sub ban_user_paste {
|
|||
my $ip = $self->get_ip_for_paste($env, $id);
|
||||
|
||||
if ($ip) {
|
||||
$self->dbh($env)->do("INSERT INTO banned_ips (ip, who, 'where') VALUES (?, ?, ?);", {}, $ip, $who, $where);
|
||||
$self->dbh($env)->do(q{INSERT INTO banned_ips (ip, who, "where") VALUES (?, ?, ?);}, {}, $ip, $who, $where);
|
||||
return "USER WAS BANNED FOR THIS POST";
|
||||
} else {
|
||||
return "Failed to find IP for paste in db";
|
||||
|
@ -83,7 +83,7 @@ sub ban_asn_paste {
|
|||
my $asn = $self->get_asn_for_paste($env, $id);
|
||||
|
||||
if ($asn) {
|
||||
$self->dbh($env)->do("INSERT INTO banned_asns (asn, who, 'where') VALUES (?, ?, ?);", {}, $asn, $who, $where);
|
||||
$self->dbh($env)->do(q{INSERT INTO banned_asns (asn, who, "where") VALUES (?, ?, ?);}, {}, $asn, $who, $where);
|
||||
return "ISP WAS BANNED FOR THIS POST";
|
||||
} else {
|
||||
return "Failed to find ISP for paste in db. yell at simcop2387; ".encrypt("[$id][$ip][$asn]");
|
||||
|
|
|
@ -62,7 +62,7 @@ sub make_pastebin_all {
|
|||
}
|
||||
}
|
||||
|
||||
my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.32 5.32.0 5.30 5.30.3 5.30.2 5.30.1 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/);
|
||||
my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.32 5.32.1 5.32.0 5.30 5.30.3 5.30.2 5.30.1 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/);
|
||||
|
||||
sub new {
|
||||
my( $class ) = @_;
|
||||
|
@ -170,6 +170,11 @@ sub command {
|
|||
if (($said->{channel} eq "#perl6" || $said->{channel} eq "#raku") && $said->{addressed} && !$said->{nested} && $orig_type =~ /^[ws]*$/) {
|
||||
$type = "perl6"
|
||||
}
|
||||
|
||||
# we were addressed, but not nested, in #perl6. Switch to perl6, otherwise use perl5
|
||||
if ($said->{channel} eq "#pdl" && !$said->{nested} && $orig_type =~ /^[ws]*$/) {
|
||||
$type = "perl5.32"
|
||||
}
|
||||
|
||||
if ($command eq 'r' && (!$said->{addressed} && !$said->{nested} && ($said->{channel} ne "#perl6" && $said->{channel} eq '#raku'))) {
|
||||
return ("handled", "");
|
||||
|
@ -264,7 +269,7 @@ sub command {
|
|||
"Columbus Day" => {prob => 0.00, chars => []},
|
||||
"Confederate Memorial Day" => {prob => 0.00, chars => []},
|
||||
"Earth Day" => {prob => 0.50, chars => ["\x{1F30E}", "\x{1F30D}", "\x{1F30F}"]},
|
||||
"Election Day" => {prob => 1.00, chars => ["\x{1F5F3}"]},
|
||||
"Election Day" => {prob => 1.00, chars => ["\x{1F5F3}\x{FE0F}"]},
|
||||
"Emancipation Day" => {prob => 0.00, chars => []},
|
||||
"Fathers Day" => {prob => 0.00, chars => []},
|
||||
"Flag Day" => {prob => 0.00, chars => []}, # TODO all country flags
|
||||
|
|
Loading…
Add table
Reference in a new issue