Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 22, 2016 17:30
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/9238fc5e80b421d7534bbae3b77e4463 to your computer and use it in GitHub Desktop.
Save zoffixznet/9238fc5e80b421d7534bbae3b77e4463 to your computer and use it in GitHub Desktop.
use lib <
/home/zoffix/CPANPRC/IRC-Client/lib
/home/zoffix/services/lib/IRC-Client/lib
lib
>;
use IRC::Client;
use IRC::Client::Plugin::HNY;
.run with IRC::Client.new:
:host(%*ENV<HNY_HOST> // 'irc.freenode.net')
:nick<HNYBot>
:channels<#perl6 #zofbot>
:debug
:plugins[
IRC::Client::Plugin::HNY.new,
];
use IRC::Client;
unit class IRC::Client::Plugin::HNY is IRC::Client::Plugin;
my \term:<☃> = DateTime.new(year => .year + (1 if .month >= 6)).utc.Instant
given DateTime.new(:year(2016), :month(12)).utc;
use WWW::Google::Time;
use Number::Denominate;
method irc-to-me ($ where /:i ^\s* 'hny' \s+ $<where>=.+ /) {
my %info = google-time-in ~$<where>
or return 'Never heard of that place…';
my \Δ = round ☃ - %info<DateTime>.Instant;
Δ <= 0
?? "New Year already happened in %info<where> &denominate(Δ) ago"
!! "New Year will happen in %info<where> in &denominate(Δ)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment