mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 10:45:40 -04:00
whoops
This commit is contained in:
parent
feafb99135
commit
e798537174
2 changed files with 157 additions and 4 deletions
63
etc/bb3.conf
63
etc/bb3.conf
|
@ -38,8 +38,25 @@ http_plugin_port 1092
|
||||||
|
|
||||||
<bot perlbot>
|
<bot perlbot>
|
||||||
channel \#buubot
|
channel \#buubot
|
||||||
|
channel \#\#turtles
|
||||||
|
channel \#perlcafe
|
||||||
channel \#webgui
|
channel \#webgui
|
||||||
|
channel \#citadel
|
||||||
|
channel \#modperl
|
||||||
|
channel \#perl
|
||||||
|
channel \#ipv6
|
||||||
channel \#perlbot
|
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 buubot
|
||||||
ignore avarbot
|
ignore avarbot
|
||||||
|
@ -57,10 +74,48 @@ http_plugin_port 1092
|
||||||
ignore EvanCarol
|
ignore EvanCarol
|
||||||
ignore EC
|
ignore EC
|
||||||
|
|
||||||
server irc.freenode.net
|
server 192.168.32.1
|
||||||
username perlbot-dev
|
username perlbot
|
||||||
password notmypassword
|
password sindarin
|
||||||
port 6667
|
port 65432
|
||||||
root_mask p3m/member/simcop2387
|
root_mask p3m/member/simcop2387
|
||||||
</bot>
|
</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>
|
||||||
|
|
98
plugins/seen.pm
Normal file
98
plugins/seen.pm
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
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'.
|
||||||
|
|
Loading…
Add table
Reference in a new issue