Created
June 22, 2013 05:46
-
-
Save kenjiskywalker/5836014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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