Skip to content

pru-mike/AnyEvent-HipChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

AnyEvent::HipChat - Build application to Atlassian Hipchat

SYNOPSIS

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;

DESCRIPTION

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.

USAGE

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.

METHODS

new(%args)

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

on($event => $sub)

$hp->on(reday => sub { .... })

Setup new event handler, for now only 'ready' event effectively supported

setup_callback($sub)

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

start()

Register callbacks and run AnyEvent::HTTPD on configured host/port

scopes()

Get scopes from capabilities descriptor

api, store, event_emitter, httpd, descriptor

Various accessors

AUTHORS

pru.mike@gmail.com

LICENSE

CC0 1.0 Universal

SEE ALSO

examples/, AnyEvent::HipChat::Api, AnyEvent::HipChat::EventEmitter, AnyEvent::HTTPD, AnyEvent::HipChat::DataStore

About

Build application to Atlassian Hipchat

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages