Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 31, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/01e41984dc3249079fa7 to your computer and use it in GitHub Desktop.
Save zoffixznet/01e41984dc3249079fa7 to your computer and use it in GitHub Desktop.
use IRC::Client::Plugin;
use WWW::Google::Time;
use Lingua::Conjunction;
use Number::Denominate;
unit class IRC::Client::Plugin::HNY:ver<1.001001> is IRC::Client::Plugin;
has Int $!short-announcement-at;
has Bool $!blah;
has Cool $!meow;
method irc-connected ($irc) {
my $utc-hny = utc-hny;
$irc.debug and say "UTC HNY is $utc-hny";
my @offsets = get-tzs;
my $prev-offset = 10;
for get-tzs() -> $tz {
announce-hny $irc, $tz;
}
}
sub announce-hny ($irc, Hash $tz, Instant :$next-new-year) {
my @countries;
for |$tz<countries> -> $country {
@countries.append: $country<name> ~ (
$country<cities>.elems ?? " [{conjunction $country<cities>}]" !! ''
);
}
my $prefix = $next-new-year ?? 'Happy New Year to'
!! "Next New Year is in {denominate $next-new-year} in";
my $res = "$prefix {conjunction @countries}";
$res = "$prefix {conjunction $tz<countries>.map: *<name>}"
unless $res.chars > 800;
for $irc.channels -> $chan {
$irc.privmsg: $chan, $_ for $res.comb: /. ** 1..400/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment