Bot-Webalert
view release on metacpan or search on metacpan
--- #YAML:1.0
name: Bot-Webalert
version: 0.01
abstract: IRC bot watches Web sites and reports changes to IRC channels
license: ~
generated_by: ExtUtils::MakeMaker version 6.31
distribution_type: module
requires:
Bot::BasicBot: 0.81
HTTP::Cookies: 5
HTTP::Request::Common: 5
Log::Log4perl: 1
POE: 1.003
POE::Component::Client::HTTP: 0.85
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
author:
- Mike Schilli <cpan@perlmeister.com>
Makefile.PL view on Meta::CPAN
######################################################################
# Makefile.PL for Bot::Webalert
# 2008, Mike Schilli <cpan@perlmeister.com>
######################################################################
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Bot::Webalert',
'VERSION_FROM' => 'Webalert.pm', # finds $VERSION
'PREREQ_PM' => {
HTTP::Request::Common => 5,
Bot::BasicBot => 0.81,
Log::Log4perl => 1,
POE => 1.003,
POE::Component::Client::HTTP => 0.85,
HTTP::Cookies => 5,
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'Webalert.pm',
AUTHOR => 'Mike Schilli <cpan@perlmeister.com>') : ()),
);
######################################################################
Bot::Webalert 0.01
######################################################################
NAME
Bot::Webalert - IRC bot watches Web sites and reports changes to IRC
channels
SYNOPSIS
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.example.com',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
);
$bot->run();
DESCRIPTION
or a string with the message it wants the bot to send to the IRC
channel. Typically, this is some explanatory text and the URL of the
watched web page, so channel users can click on the link to see what's
new.
The easiest way to write a web-watching bot is to let Bot::Webalert use
its default response handler, which posts a message whenever the watched
web page changes:
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.example.com',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
);
$bot->run();
This will fetch the URL specified once per hour and call Bot::Webalert's
different from the previous one. The message sent by the default handler
looks like
webalert-bot says: http://foobar.com has changed!
and will be sent to all channels specified in the "channels" option. If
you'd like to customize the message or have better control over what
kind of changes are reported, write your own response handler:
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.freenode.net',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
ua_fetch_interval => 60, # check every minute
ua_callback => \&response_handler,
);
my $old_content = "";
Webalert.pm view on Meta::CPAN
__END__
=head1 NAME
Bot::Webalert - IRC bot watches Web sites and reports changes to IRC channels
=head1 SYNOPSIS
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.example.com',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
);
$bot->run();
=head1 DESCRIPTION
Webalert.pm view on Meta::CPAN
undef or a string with the message it wants the bot to send to the
IRC channel. Typically, this is some explanatory text and the URL of
the watched web page, so channel users can click on the link to see
what's new.
The easiest way to write a web-watching bot is to let Bot::Webalert use
its default response handler, which posts a message whenever the watched
web page changes:
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.example.com',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
);
$bot->run();
This will fetch the URL specified once per hour and call
Webalert.pm view on Meta::CPAN
web server's response is different from the previous one. The message
sent by the default handler looks like
webalert-bot says: http://foobar.com has changed!
and will be sent to all channels specified in the C<channels> option.
If you'd like to customize the message or have better control over what kind
of changes are reported, write your own response handler:
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.freenode.net',
channels => ["#friends_of_webalert"],
ua_request => GET("http://somewhere/changes.rss"),
ua_fetch_interval => 60, # check every minute
ua_callback => \&response_handler,
);
my $old_content = "";
eg/webalert-bot view on Meta::CPAN
#!/usr/local/bin/perl -w
###########################################
# webalert-bot
# Mike Schilli, 2008 (m@perlmeister.com)
###########################################
use strict;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);
use Bot::Webalert;
use HTTP::Request::Common;
my $bot = Bot::Webalert->new(
server => 'irc.freenode.net',
channels => ["#friends_of_webalert"],
ua_request => GET("http://www.yahoo.com"),
ua_fetch_interval => 60, # check every minute
);
my $old_content = "";
t/001Basic.t view on Meta::CPAN
######################################################################
# Test suite for Bot::Webalert
# by Mike Schilli <cpan@perlmeister.com>
######################################################################
use warnings;
use strict;
use Test::More;
use Bot::Webalert;
use HTTP::Request::Common;
use POE::Kernel;
plan tests => 2;
eval { my $bot = Bot::Webalert->new(); };
like $@, qr/Missing mandatory parameters/, "parameter check";
my $bot = Bot::Webalert->new(
server => 'irc.freenode.net',
( run in 0.367 second using v1.01-cache-2.11-cpan-de7293f3b23 )