Skype に issue 番号に反応する bot がいると捗る

"IRC に issue 番号に反応する bot がいると捗る" らしいので - @soh335 memo より

use strict;
use warnings;
use Skype::Any;
use AnyEvent::HTTP;
use JSON::XS;
use Try::Tiny;
use HTTP::Request::Common;

my $owner;
my $repos;

my $github_user;
my $github_password;

my $skype = Skype::Any->new(name => 'issue-chan');

$skype->message_received(sub {
    my ($msg) = @_;
    my @numbers = $msg->body =~ /#(\d+)/g;

    for my $number ( @numbers ) {
        my $req = GET sprintf(
            "https://api.github.com/repos/%s/%s/issues/%d",
            $owner,
            $repos,
            $number
        );
        $req->authorization_basic($github_user, $github_password);
        my %headers = map { $_ => $req->header($_) } $req->headers->header_field_names;

        my $g; $g = http_get $req->uri, headers => \%headers, sub {
            my ($body, $hdr) = @_;
            return unless $hdr->{Status} =~ /^2/;

            try {
                my $json = decode_json $body;
                $msg->chat->send_message(
                    sprintf "#%d %s %s", $json->{number}, $json->{title}, $json->{html_url}
                );
            }
            catch {
                warn $_;
            }
            finally {
                undef $g;
            };
        };
    }
});

$skype->run;

Skype::Any、ちょろっと書き直したやつを手元のリポジトリに放置しているのでひどい。
あとSkype botをうまく運用する方法とかまとめておきたいけど気力がなくて、これも放置しております。