Skip to content

Instantly share code, notes, and snippets.

@Skarsnik Skarsnik/supply.p6
Created Mar 19, 2019

What would you like to do?
use API::Discord;
#use IRC::Client;
use Config::Simple;
use GithubNotif;
use HTTP::Tinyish;
my $ua =;
my $config ="auth-token.p6");
my $discord-token = $config<discord-token>;
my $github-token = $config<github-token>;
my $discord =$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
You can’t perform that action at this time.