Created
March 19, 2019 21:31
-
-
Save Skarsnik/36d62955b18fdb82ab5cb8feaaaa7a20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
use API::Discord; | |
#use IRC::Client; | |
use Config::Simple; | |
use GithubNotif; | |
use HTTP::Tinyish; | |
my $ua = HTTP::Tinyish.new; | |
#https://discordapp.com/api/oauth2/authorize?client_id=555485913912836106&scope=bot&permissions=2048 | |
my $config = Config::Simple.read("auth-token.p6"); | |
my $discord-token = $config<discord-token>; | |
my $github-token = $config<github-token>; | |
my $discord = API::Discord.new(:token($discord-token)); | |
await $discord.connect; | |
say "Connected"; | |
await $discord.ready; | |
say "Ready"; | |
await github-notif-init($github-token, $discord); | |
react { | |
whenever $discord.messages -> $message { | |
} | |
whenever supply { | |
loop { | |
my $res = $ua.get: $GITHUB_API_URL, :headers{ :Authorization("token $github-token") }; | |
say "Getting GH notification : ", $res<success>; | |
#say from-json $res<content>; | |
$res<success> and emit (from-json $res<content>).grep: {$_<unread> == True}; | |
sleep $res<headers><X-Poll-Interval> || 60; | |
} | |
} -> @events { | |
say "Notifications : ", +@events, " events"; | |
gh-process-event($_) for @events; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment