Skip to content

Instantly share code, notes, and snippets.

@masak
Created September 18, 2009 13:06
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 masak/189041 to your computer and use it in GitHub Desktop.
Save masak/189041 to your computer and use it in GitHub Desktop.
use v6;
use IRC::Client;
class BirthdayTracker is IRC::Client {
has $!name = 'birdie';
has %!birthdays;
has %!last-congratulated;
regex date { ... }
method record(Session $_) is triggered(
/:sigspace $name ':' my birthday is <date>/) {
%!birthdays{.person} = $/<date>;
.reply("Ok, $.person");
}
method congratulate(Session $_) is triggered(*) {
if %!birthdays{.person} === today()
&& %!last-congratulated{.person} < today() {
.reply("Hey, happy birthday, $.person!");
%!last-congratulated{.person} = today();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment