mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 18:25:42 -04:00
fix some table issues
This commit is contained in:
parent
c37e28511e
commit
feafb99135
3 changed files with 14 additions and 157 deletions
63
etc/bb3.conf
63
etc/bb3.conf
|
@ -38,25 +38,8 @@ http_plugin_port 1092
|
|||
|
||||
<bot perlbot>
|
||||
channel \#buubot
|
||||
channel \#\#turtles
|
||||
channel \#perlcafe
|
||||
channel \#webgui
|
||||
channel \#citadel
|
||||
channel \#modperl
|
||||
channel \#perl
|
||||
channel \#ipv6
|
||||
channel \#perlbot
|
||||
channel \#mrtg
|
||||
channel \#ipv6-fr
|
||||
channel \#freebsd-fr
|
||||
channel \#botpark
|
||||
channel \#css
|
||||
channel \#modus
|
||||
channel \#perl-cats
|
||||
channel \#cout.dev
|
||||
channel \#web-locals
|
||||
channel \#regex
|
||||
channel \#regexen
|
||||
|
||||
ignore buubot
|
||||
ignore avarbot
|
||||
|
@ -74,48 +57,10 @@ http_plugin_port 1092
|
|||
ignore EvanCarol
|
||||
ignore EC
|
||||
|
||||
server 192.168.32.1
|
||||
username perlbot
|
||||
password sindarin
|
||||
port 65432
|
||||
server irc.freenode.net
|
||||
username perlbot-dev
|
||||
password notmypassword
|
||||
port 6667
|
||||
root_mask p3m/member/simcop2387
|
||||
</bot>
|
||||
|
||||
<bot perlbot-magnet>
|
||||
channel \#freenode-perl-cabal
|
||||
channel \#perl-help
|
||||
|
||||
ignore purl
|
||||
ignore perlbot
|
||||
|
||||
server 192.168.32.1
|
||||
username perlbot-magnet
|
||||
password sindarin
|
||||
port 65432
|
||||
root_mask ~simcop238@simcop2387.info
|
||||
</bot>
|
||||
<bot perlbot-oftc>
|
||||
channel \#perlbot
|
||||
channel \#perl
|
||||
|
||||
ignore purl
|
||||
ignore perlbot
|
||||
|
||||
server 192.168.32.1
|
||||
username perlbot-oftc
|
||||
password sindarin
|
||||
port 65432
|
||||
root_mask ~simcop238@simcop2387.info
|
||||
</bot>
|
||||
<bot perlbot-efnet>
|
||||
channel \#perl
|
||||
|
||||
ignore purl
|
||||
ignore perlbot
|
||||
|
||||
server 192.168.32.1
|
||||
username perlbot-efnet
|
||||
password sindarin
|
||||
port 65432
|
||||
root_mask ~simcop238@simcop2387.info
|
||||
</bot>
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package Bot::BB3::Plugin::Seen;
|
||||
use POE::Component::IRC::Common qw/l_irc/;
|
||||
use DBD::SQLite;
|
||||
use strict;
|
||||
|
||||
sub new {
|
||||
my( $class ) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->{name} = "seen";
|
||||
$self->{opts} = {
|
||||
command => 1,
|
||||
handler => 1,
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub dbh {
|
||||
my( $self ) = @_;
|
||||
|
||||
if( $self->{dbh} and $self->{dbh}->ping ) {
|
||||
return $self->{dbh};
|
||||
}
|
||||
|
||||
my $dbh = $self->{dbh} = DBI->connect( "dbi:SQLite:dbname=var/seen.db", "", "", { PrintError => 0, RaiseError => 1 } );
|
||||
|
||||
return $dbh;
|
||||
}
|
||||
sub postload {
|
||||
my( $self, $pm ) = @_;
|
||||
|
||||
|
||||
my $sql = "CREATE TABLE seen (
|
||||
seen_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user VARCHAR(25),
|
||||
lc_user VARCHAR(25),
|
||||
message VARCHAR(250),
|
||||
seen_date INTEGER
|
||||
);";
|
||||
|
||||
$pm->create_table( $self->dbh, "seen", $sql );
|
||||
|
||||
delete $self->{dbh}; # UGLY HAX GO.
|
||||
# Basically we delete the dbh we cached so we don't fork
|
||||
# with one active
|
||||
}
|
||||
|
||||
sub command {
|
||||
my( $self, $said, $pm ) = @_;
|
||||
my( $target ) = @{ $said->{recommended_args} };
|
||||
|
||||
return () unless $said->{addressed};
|
||||
|
||||
my $seen = $self->dbh->selectrow_arrayref( "SELECT user,message,seen_date FROM seen WHERE lc_user = ?",
|
||||
undef,
|
||||
l_irc( $target )
|
||||
);
|
||||
|
||||
if( $seen and @$seen and $seen->[0] ) {
|
||||
|
||||
return( 'handled', "I last saw $seen->[0] saying \"$seen->[1]\" at " . gmtime($seen->[2]) . " Z." );
|
||||
}
|
||||
else {
|
||||
return( 'handled', "I don't think I've seen $target." );
|
||||
}
|
||||
}
|
||||
|
||||
sub handle {
|
||||
my ( $self, $said, $pm ) = @_;
|
||||
eval {
|
||||
my $count = $self->dbh->do( "UPDATE seen SET user = ?, message = ?, seen_date = ? WHERE lc_user = ?",
|
||||
undef,
|
||||
$said->{name},
|
||||
$said->{body},
|
||||
time(),
|
||||
l_irc( $said->{name} ),
|
||||
);
|
||||
|
||||
if( $count == 0 ) {
|
||||
$self->dbh->do( "INSERT INTO seen (user,lc_user,message,seen_date) VALUES ( ?,?,?,? )",
|
||||
undef,
|
||||
$said->{name},
|
||||
l_irc($said->{name}),
|
||||
$said->{body},
|
||||
time(),
|
||||
);
|
||||
}
|
||||
}; # ignore errors from database during non-addressed writes.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
no warnings 'void';
|
||||
"Bot::BB3::Plugin::Seen";
|
||||
|
||||
__DATA__
|
||||
The seen plugin. Attempts to keep track of every user the bot has 'seen'. Use the syntax, seen user; to ask the bot when it last saw the user named 'user'.
|
||||
|
|
@ -4,10 +4,20 @@ BEGIN;
|
|||
DROP TABLE IF EXISTS public.factoid;
|
||||
CREATE TABLE public.factoid AS (SELECT * FROM sqlite.factoid);
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS factoid_factoid_id_seq AS bigint OWNED BY public.factoid.factoid_id;
|
||||
SELECT setval('factoid_factoid_id_seq', (select max(factoid_id)+1 from public.factoid));
|
||||
ALTER TABLE public.factoid ALTER COLUMN factoid_id SET DEFAULT nextval('factoid_factoid_id_seq');
|
||||
ALTER TABLE public.factoid ALTER COLUMN factoid_id SET NOT NULL;
|
||||
ALTER TABLE public.factoid ADD PRIMARY KEY (factoid_id);
|
||||
|
||||
ALTER TABLE public.factoid ALTER COLUMN original_subject TYPE text;
|
||||
ALTER TABLE public.factoid ALTER COLUMN original_subject SET NOT NULL;
|
||||
ALTER TABLE public.factoid ALTER COLUMN subject TYPE text;
|
||||
ALTER TABLE public.factoid ALTER COLUMN subject SET NOT NULL;
|
||||
ALTER TABLE public.factoid ALTER COLUMN copula TYPE text;
|
||||
ALTER TABLE public.factoid ALTER COLUMN copula SET NOT NULL;
|
||||
ALTER TABLE public.factoid ALTER COLUMN author TYPE text;
|
||||
ALTER TABLE public.factoid ALTER COLUMN author SET NOT NULL;
|
||||
ALTER TABLE public.factoid ADD COLUMN deleted boolean DEFAULT false;
|
||||
ALTER TABLE public.factoid ADD COLUMN namespace text;
|
||||
ALTER TABLE public.factoid ADD COLUMN server text;
|
||||
|
|
Loading…
Add table
Reference in a new issue