Bot-Cobalt
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
[POE::Component::IRC](https://metacpan.org/pod/POE::Component::IRC); the bot can
comfortably manage multiple servers/networks (referred to as
"contexts").
Bot::Cobalt tries to be friendly to developers. The bridge to
[POE::Component::IRC](https://metacpan.org/pod/POE::Component::IRC) exists as a plugin and can be easily subclassed
or replaced entirely; see [Bot::Cobalt::IRC](https://metacpan.org/pod/Bot::Cobalt::IRC).
Plugin authoring is intended to be as easy as possible. Modules are
included to provide simple frontends to IRC-related
utilities, logging, plugin configuration, asynchronous HTTP
sessions, data serialization and on-disk databases, and more. See
[Bot::Cobalt::Manual::Plugins](https://metacpan.org/pod/Bot::Cobalt::Manual::Plugins) for more about plugin authoring.
## Initializing a new instance
A Bot::Cobalt instance needs its own _etc/_ and _var/_ directories. With
the default frontend (`cobalt2`), these are specified in a simple
'rcfile' for each particular instance.
sh$ cobalt2-installer
lib/Bot/Cobalt.pm view on Meta::CPAN
L<POE::Component::IRC>; the bot can
comfortably manage multiple servers/networks (referred to as
"contexts").
Bot::Cobalt tries to be friendly to developers. The bridge to
L<POE::Component::IRC> exists as a plugin and can be easily subclassed
or replaced entirely; see L<Bot::Cobalt::IRC>.
Plugin authoring is intended to be as easy as possible. Modules are
included to provide simple frontends to IRC-related
utilities, logging, plugin configuration, asynchronous HTTP
sessions, data serialization and on-disk databases, and more. See
L<Bot::Cobalt::Manual::Plugins> for more about plugin authoring.
=head2 Initializing a new instance
A Bot::Cobalt instance needs its own I<etc/> and I<var/> directories. With
the default frontend (C<cobalt2>), these are specified in a simple
'rcfile' for each particular instance.
sh$ cobalt2-installer
lib/Bot/Cobalt/Manual/Plugins.pod view on Meta::CPAN
=head3 Bot::Cobalt::Plugin::WWW
It's fairly common to want to make some kind of HTTP request from an
IRC bot. The most common Perl method of speaking HTTP is
L<LWP::UserAgent> -- which will block the plugin pipeline until the
request is complete.
L<Bot::Cobalt::Plugin::WWW>, if loaded, dispatches HTTP requests
asynchronously via L<POE::Component::Client::HTTP> and returns
L<HTTP::Response> responses to the plugin pipeline:
## build a request object via HTTP::Request
use HTTP::Request;
## a simple GET, see HTTP::Request docs for more info:
my $request = HTTP::Request->new( 'GET', $url );
## push it to www_request with a response event:
broadcast( 'www_request',
lib/Bot/Cobalt/Plugin/Extras/DNS.pm view on Meta::CPAN
## Convert an IPv4 address to its hexadecimal representation:
!iptohex 127.0.0.1
## Reverse of above:
!hextoip 7f000001
=head1 DESCRIPTION
A Cobalt plugin providing DNS query results on IRC.
Uses L<POE::Component::Client::DNS> for asynchronous lookups.
Also performs some rudimentary address manipulation.
=head1 AUTHOR
Jon Portnoy <avenj@cobaltirc.org>
=cut
lib/Bot/Cobalt/Plugin/RDB/AsyncSearch.pm view on Meta::CPAN
## These should sigchld and go away.
}
1;
__END__
=pod
=head1 NAME
Bot::Cobalt::Plugin::RDB::AsyncSearch - Asynchronous RDB deep search
=head1 SYNOPSIS
## Inside a POE::Session
my $async_sessID = Bot::Cobalt::Plugin::RDB::AsyncSearch->spawn(
MaxWorkers => 5,
ResultEvent => 'got_rdb_result',
ErrorEvent => 'got_rdb_error',
);
lib/Bot/Cobalt/Plugin/WWW.pm view on Meta::CPAN
core()->Provided->{www_request} = __PACKAGE__ ;
}
1;
__END__
=pod
=head1 NAME
Bot::Cobalt::Plugin::WWW - Asynchronous HTTP requests from Cobalt plugins
=head1 SYNOPSIS
## Send your request, specify an event to handle response:
use HTTP::Request;
my $request = HTTP::Request->new(
'GET',
'http://www.cobaltirc.org'
);
lib/Bot/Cobalt/Plugin/WWW.pm view on Meta::CPAN
## HTTP::Response object:
my $response = ${ $_[1] };
## Attached arguments array reference:
my $args_arr = ${ $_[2] };
return PLUGIN_EAT_ALL
}
=head1 DESCRIPTION
This plugin provides an easy interface to asynchronous HTTP requests; it
bridges Cobalt's plugin pipeline and L<POE::Component::Client::HTTP> to
provide responses to B<Bot_www_request> events.
The request should be a L<HTTP::Request> object.
Inside the response handler, $_[1] will contain the L<HTTP::Response>
object; $_[0] is the undecoded content if the request was successful or
some error from L<HTTP::Status> if not.
Arguments can be attached to the request event and retrieved in the
share/etc/plugins.conf view on Meta::CPAN
Seen:
## !seen command
Module: Bot::Cobalt::Plugin::Seen
Version:
## 'Version' provides 'os' 'version' 'info' responses:
Module: Bot::Cobalt::Plugin::Version
WWW:
Priority: 80
## Provides asynchronous HTTP functionality to Web-related plugins
## You probably want this loaded.
Module: Bot::Cobalt::Plugin::WWW
Config: plugins/www.conf
######################### Extras #############################
## A handful of plugins providing useful or fun functionality.
CPAN:
## MetaCPAN interface.
## Provides !cpan <query> <distname>
share/etc/plugins/rdb.conf view on Meta::CPAN
## Set to an access level to enable for that level.
AllowDeleteMain: 0
## Delay at which we should broadcast random stuff out of 'main'
## Will send to any channels not marked as 'rdb_randstuffs: 0' in
## channels.conf
## Should be a timestr such as '20m' or '1h30m' or even '1h5m10s'
## Set to 0 to disable timed 'random stuff' altogether
RandDelay: '30m'
## AsyncSearch will use forking asynchronous workers to run deep
## searches against RDBs; unless your RDBs are very large, this is
## very possibly more overhead than it is worth.
##
## Enabled if boolean true; if greater than 1, it is taken as the
## maximum number of concurrent search workers; defaults to 5.
##
## Don't bother on Win32 -- Windows doesn't have a proper fork(),
## and the overhead probably sucks.
AsyncSearch: 0
share/etc/plugins/www.conf view on Meta::CPAN
---
## Plugin::WWW config
##
## The 'WWW' plugin handles asynchronous HTTP for Web-enabled plugins.
## You probably want this loaded, else some plugins may silently fail.
##
## For most configurations, the defaults here should be fine.
Opts:
## The 'MaxWorkers' opt is misleadingly named.
##
## Previously this plugin forked off LWP::UserAgent instances.
## Now it uses POE::Component::Client::HTTP.
## Rather than throttling the number of forked workers, now this
( run in 0.358 second using v1.01-cache-2.11-cpan-0d8aa00de5b )