Created
September 18, 2009 13:06
-
-
Save masak/189041 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 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