Bot-Cobalt
view release on metacpan or search on metacpan
lib/Bot/Cobalt/IRC/Event/Topic.pm view on Meta::CPAN
my $new_topic = $topic_ev->topic;
=head1 DESCRIPTION
This is the L<Bot::Cobalt::IRC::Event::Channel> subclass for channel topic
changes.
=head2 topic
Returns the new channel topic, as an (undecoded and non-stripped)
string.
=head2 stripped
Returns the color- and formatting-stripped topic string.
=head1 AUTHOR
Jon Portnoy <avenj@cobaltirc.org>
lib/Bot/Cobalt/Manual/Plugins.pod view on Meta::CPAN
## here's an example args arrayref telling our handler
## where to send responses:
[ $context, $channel, $nickname ],
);
## handle a response when one is received:
sub Bot_myplugin_resp_recv {
my ($self, $core) = splice @_, 0, 2;
## if the request was successful, $_[0] is a ref to the
## decoded content from HTTP::Response
## (otherwise, it is the HTTP status message)
my $content = ${ $_[0] };
## $_[1] is the HTTP::Response object, see perldoc HTTP::Response
my $response = ${ $_[1] };
## $_[2] is whatever argument ref was provided in www_request
my $argref = ${ $_[2] };
## in our example above, it was some contextual info:
lib/Bot/Cobalt/Plugin/WWW.pm view on Meta::CPAN
my $this_req = delete $self->Requests->{$tag};
return unless $this_req;
my $event = $this_req->{Event};
my $args = $this_req->{Args};
core->log->debug("ht_response dispatch: $event ($tag)");
my $content = $response->is_success ?
$response->decoded_content
: $response->message;
broadcast($event, $content, $response, $args);
}
sub _start {
my ($self, $kernel) = @_[OBJECT, KERNEL];
my $sess_alias = 'www_'. core()->get_plugin_alias($self);
$kernel->alias_set( $sess_alias );
lib/Bot/Cobalt/Plugin/WWW.pm view on Meta::CPAN
=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
handler via $_[2] -- this is usually an array reference, but anything
that fits in a scalar will do.
Plugin authors should check for the boolean value of B<<
$core->Provided->{www_request} >> and possibly fall back to using LWP
with a short timeout if they'd like to continue to function if this
plugin is B<not> loaded.
( run in 0.524 second using v1.01-cache-2.11-cpan-26ccb49234f )