NAME

IRC::Bot::Log::Extended - extends IRC::Bot::Log for IRC::Bot

SYNOPSIS

#!/usr/bin/perl -w

package IRC::Bot2;

use Moose;
extends 'IRC::Bot';
use IRC::Bot::Log::Extended;

after 'bot_start' => sub {
    my $self = shift;

    no warnings;
    $IRC::Bot::log =  IRC::Bot::Log::Extended->new(
        Path          => $self->{'LogPath'},
        split_channel => 1,
        split_day     => 1,
    );
};

package main;

# Initialize new object
my $bot = IRC::Bot2->new( # check IRC::Bot for more details
    Debug    => 0,
    Nick     => 'Fayland',
    Server   => 'irc.perl.org',
    Channels => [ '#moose', '#catalyst', '#dbix-class' ],
    LogPath  => '/home/fayland/irclog/',
);

# Daemonize process
$bot->daemon();

# Run the bot
$bot->run();

1;

DESCRIPTION

The SYNOPSIS above does two tasks.

  1. it creates a custom IRC::Bot2 based on IRC::Bot. The only differece is override $IRC::Bot::log with

    $IRC::Bot::log =  IRC::Bot::Log::Extended->new(
        Path          => $self->{'LogPath'},
        split_channel => 1,
        split_day     => 1,
    );
  2. the usage of IRC::Bot2 is the same as IRC::Bot. no difference. read IRC::Bot for configuration and usage.

ATTRIBUTES

IRC::Bot::Log stores all channels all days into one file channel.log. it is not so good to read. IRC::Bot::Log::Extended splits the log into several files by channel AND|OR day.

Path

the place moose_20081009.log stores.

split_channel

default is 1. Instead store all log into channel.log, we split them into moose.log, catalyst.log and dbix-class.log

split_day

default is 1. Instead store all log into channel.log or moose.log, we split them into channel_20081009.log, channel_20081010.log (moose_20081010.log) and etc. daily.

AUGMENTABLE METHODS

The method pre_insert can be augmented in a subclass to add extra functionality to your control script. here is two examples:

http://fayland.googlecode.com/svn/trunk/CPAN/IRC-Bot-Log-Extended/examples/02b_with_filter.pl

http://fayland.googlecode.com/svn/trunk/CPAN/IRC-Bot-Log-Extended/examples/03advanced.pl

augment pre_insert => sub {
  my ($self, $file_ref, $message_ref) = @_;
  
  # change filename
  $$file_ref .= '.html';
  
  # HTML-lize
  $$message_ref =~ s/\</\&lt\;/isg;
  
  # find URIs
  my $finder = URI::Find->new(
      sub {
          my ( $uri, $orig_uri ) = @_;
          return qq|<a href="$uri">$orig_uri</a>|;
      }
  );
  $finder->find( $message_ref );
  
  $$message_ref .= "</br>";
};

the example above is to make a HTML IRC log by youself.

SEE ALSO

IRC::Bot, IRC::Bot::Log, Moose

AUTHOR

Fayland Lam, <fayland at gmail.com>

COPYRIGHT & LICENSE

Copyright 2008 Fayland Lam, all rights reserved.

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