AnyEvent::HipChat - Build application to Atlassian Hipchat
my $hp = AnyEvent::HipChat->new(
webhook_iface => $interface,
webhook_port => $port,
data_storage => <storage class, optional>,
descriptor => <hipchat capabilities descriptor>
);
$hp->on(
ready => sub {
my $store = shift;
my $room_id = $store->room_id;
my $api = $store->api;
.... #doing something very useful here
}
);
$hp->start;
Framework to build application to Atlassian Hipchat platform. It's contain two major parts: AnyEvent::HipChat::Api - api client library, AnyEvent::HipChat - hipchat http callback handler.
Basic usage scenario
- setup
-
Provide interface, prort and capabilities descriptor to AnyEvent::HipChat constructor
- on->ready
-
Setup some callbacks with very useful scenario via ready event
- setup_callback
-
Setup some user defined callback handlers (e.g. for room message processing)
- start
-
Make AnyEvent::HipChat framework to listen hipchat callback.
Constructor, provide following options:
- webhook_iface, required
-
Listening interface address, required There is no default, and it MUST be real network interface no 0.0.0.0.
- webhook_port
-
AnyEvent::Hipchat port, default 65500
- httpd_args
-
Something that you wand to send to AnyEvent::HTTPD-new(...)>
- descriptor
-
Hipchat capability descriptor goes here. Note that there is reasonable default
{ name => ucfirst(lc(Sys::Hostname::hostname)). " hipchat integration", description => 'An integration that make cool stuff', key => Sys::Hostname::hostname, links => { ... }, capabilities => { hipchatApiConsumer => { scopes => [ qw/send_message/ ] }, "installable" => { ... }, } };
- data_storage
-
Instanse of class that support AnyEvent::HipChat::DataStore interface
$hp->on(reday => sub { .... })
Setup new event handler, for now only 'ready' event effectively supported
my $cb_url =
$hp->setup_callback(sub {
my ($ok, $data, $err) = @_;
...
});
$api->create_room_webhook(
url => $cb_url,
event => 'room_message',
room_id => $room_id,
key => $room_hook_key,
sub {
my ($ok, $data, $err) = @_;
...
});
Setup user defined callback
Register callbacks and run AnyEvent::HTTPD on configured host/port
Get scopes from capabilities descriptor
Various accessors
pru.mike@gmail.com
CC0 1.0 Universal
examples/, AnyEvent::HipChat::Api, AnyEvent::HipChat::EventEmitter, AnyEvent::HTTPD, AnyEvent::HipChat::DataStore