The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bot::BasicBot::Pluggable::Module::SimpleBlog - A simple URL collector for Bot::BasicBot::Pluggable.

SYNOPSIS

  use Bot::BasicBot::Pluggable;
  use Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::SQLite;

  my $bot = Bot::BasicBot::Pluggable->new( ... );
  $bot->load( "SimpleBlog" );

  my $blog_handler = $bot->handler( "SimpleBlog" );

  $blog_handler->set_store(
    Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::SQLite
       ->new( "/home/bot/brane.db" )
  );

  $blog_handler->set_blogurl( "http://example.com/simpleblog.cgi" );

  $bot->run;

DESCRIPTION

A plugin module for Bot::BasicBot::Pluggable to grab, store and output URLs from IRC channels. It is intentionally simplistic - see Bot::BasicBot::Pluggable::Module::Blog for a more complicated chump-like thing.

IMPORTANT NOTE WHEN UPGRADING FROM PRE-0.02 VERSIONS

I'd made a thinko in version 0.01 in one of the column names in the table used to store the URLs in the database, so you'll have to delete your store file and start again. It didn't seem worth automatically detecting and fixing this since I only released 0.01 yesterday and I don't expect anyone to have installed it yet.

METHODS

set_store
  my $blog_store =
    Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::SQLite->new(
      "/home/bot/brane.db" );
  $blog_handler->set_store( $blog_store );

Supply a Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::* object.

set_blogurl
  $blog_handler->set_blogurl( "http://example.com/simpleblog.cgi" );

Supply the URL for your CGI script to view the stored URLs.

EXAMPLES

  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( "SimpleBlog" );

  my $blog_handler = $bot->handler( "SimpleBlog" );

  $blog_handler->set_store(
    Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::SQLite
       ->new( "/home/bot/brane.db" )
  );

  $blog_handler->set_blogurl( "http://example.com/simpleblog.cgi" );

  $bot->run;

Yes, this is your entire program.

The file supplied as an argument to the constructor of Bot::BasicBot::Pluggable::Module::SimpleBlog::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> kakebot: help SimpleBlog
  <kakebot> nou: Simple URL collector for Bot::BasicBot::Pluggable.
      Requires direct addressing.  Usage:
      'http://foo.com/ # the foo website'.  The URLs can be viewed at
      http://example.com/simpleblog.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>simpleblogbot</title></head>
  <body><h1 align="center">simpleblogbot</h1>

  EOF

  my $sql = "SELECT timestamp, name, channel, url, comment FROM blogged
             ORDER BY timestamp DESC";
  my $sth = $dbh->prepare($sql) or die $dbh->errstr;
  $sth->execute;
  my ($timestamp, $name, $channel, $url, $comment);

  while ( ($timestamp, $name, $channel, $url, $comment)
                                          = $sth->fetchrow_array ) {
      print "<br><i>$timestamp</i>: <b>$name/$channel</b>: ";
      print "<a href=\"$url\">$url</a> " if $url;
      print $q->escapeHTML($comment) if $comment;
  }

  print "</body></html>\n";

(This will just print everything ever; being more discriminating and adding prettiness is left as an exercise for people who don't hate writing CGI scripts.)

At some point there will be Bot::BasicBot::Pluggable::Module::Store::* methods for retrieving as well as storing the data. Probably.

WARNING

Unstable API - Bot::BasicBot::Pluggable is liable to change and hence so is this.

BUGS

More tests would be nice.

SEE ALSO

AUTHOR

Kake Pugh (kake@earth.li).

COPYRIGHT

     Copyright (C) 2003 Kake Pugh.  All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

CREDITS

Tom Insam, author of Bot::BasicBot::Pluggable, answered my dumb questions on how to get it working. Mark Fowler fixed my bad SQL, and told me off until I agreed to abstract out the storage and retrieval bits.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 133:

You forgot a '=back' before '=head1'