-
-
Save zoffixznet/01e41984dc3249079fa7 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
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