Bot::BasicBot::Pluggable::Module::Notes - A simple note collector for Bot::BasicBot::Pluggable.
use Bot::BasicBot::Pluggable; use Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite; my $bot = Bot::BasicBot::Pluggable->new( ... ); $bot->load( "Notes" ); my $notes_handler = $bot->handler( "Notes" ); $notes_handler->set_store( Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite ->new( "/home/bot/brane.db" ) ); $notes_handler->set_notesurl( "http://example.com/irc-notes.cgi" ); $bot->run;
A plugin module for Bot::BasicBot::Pluggable to store notes for IRC users, these are just stuffed into a small database (SQLite store provided) by time, user and content. Notes taken can then be later viewed on the web using a small web app (provided).
my $notes_store = Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite->new( "/home/bot/brane.db" ); $notes_handler->set_store( $notes_store );
Supply a Bot::BasicBot::Pluggable::Module::Notes::Store::* object.
Bot::BasicBot::Pluggable::Module::Notes::Store::*
$notes_handler->set_notesurl( "http://example.com/irc-notes.cgi" );
Supply the URL for your CGI/App script to view the stored Notes.
use strict; use warnings; use Bot::BasicBot::Pluggable; my $bot = Bot::BasicBot::Pluggable->new(channels => [ "#test" ], server => "irc.example.com", port => "6667", nick => "bot", username => "bot", name => "bot", ); $bot->load( "Notes" ); my $notes_handler = $bot->handler( "Notes" ); $notes_handler->set_store( Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite ->new( "/home/bot/brane.db" ) ); $notes_handler->set_notesurl( "http://example.com/irc-notes.cgi" ); $bot->run;
Yes, this is your entire program.
The file supplied as an argument to the constructor of Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite need not already exist; it will be created and the correct database schema set up as necessary.
Talk to the bot on IRC for help:
17:37 <nou> notesbot: help Notes <notesbot> nou: Simple Note collector for Bot::BasicBot::Pluggable. Requires direct addressing. Usage: 'note to self: Here's something for later'. The Notes can be viewed at http://example.com/irc-notes.cgi
Get stuff out of the database in your favoured fashion, for example:
use strict; use warnings; use CGI; use DBI; my $sqlite_db = "/home/bot/brane.db"; my $q = CGI->new; my $dbh = DBI->connect("dbi:SQLite:dbname=$sqlite_db", "", "") or die DBI->errstr; print $q->header; print <<EOF; <html> <head><title>notes</title></head> <body><h1 align="center">notes</h1> EOF my $sql = "SELECT timestamp, name, channel, notes FROM notes ORDER BY timestamp DESC"; my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute; my ($timestamp, $name, $channel, $notes); while ( ($timestamp, $name, $channel, $notes) = $sth->fetchrow_array ) { print "<br><i>$timestamp</i>: <b>$name/$channel</b>: "; print "$notes<br>"; } print "</body></html>\n";
More tests would be nice.
Module shamelessly stolen and slightly modified from Bot::BasicBot::Pluggable::Module::SimpleBlog by Kake.
Many things: Include web interface, have bot repeat back stored things, parse/store tags..
Bot::BasicBot::Pluggable
Bot::BasicBot::Pluggable::Module::Notes::Store::SQLite
Jess Robinson <castaway@desert-island.me.uk>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Bot::BasicBot::Pluggable::Module::Notes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::BasicBot::Pluggable::Module::Notes
CPAN shell
perl -MCPAN -e shell install Bot::BasicBot::Pluggable::Module::Notes
For more information on module installation, please visit the detailed CPAN module installation guide.