Skip to content

Instantly share code, notes, and snippets.

@kenjiskywalker
Created June 22, 2013 05:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenjiskywalker/5836014 to your computer and use it in GitHub Desktop.
Save kenjiskywalker/5836014 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use AnyEvent;
use LWP::Simple;
use Try::Tiny;
use JSON qw/decode_json/;
use String::IRC;
my $cv = AE::cv;
my $previous = undef;
### {"status":"good","body":"Everything operating normally.","created_on":"2013-06-20T10:09:23Z"}
my $contents = get('https://status.github.com/api/last-message.json');
my @c = decode_json($contents);
my $st = "status:" . $c[0]->{'status'} . " \"" . $c[0]->{'body'} . "\" created_on " . $c[0]->{'created_on'} . "\n";
### for Color.
my $color_status = String::IRC->new($st);
### every 30sec check.
my $w = AE::timer 0, 30, sub {
try {
my $contents = get('https://status.github.com/api/last-message.json');
if (defined $previous && $previous ne $contents) {
`curl -s -F channel=\#kenjiskywalker -F message='$color_status' http://localhost:4780/privmsg`
}
$previous = $contents;
} catch {
warn('error: %s', $_);
};
};
$cv->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment