From ccff1c8b1e32b4e3268ee8201b213a326ad17d2c Mon Sep 17 00:00:00 2001 From: nemunaire Date: Mon, 11 Aug 2014 14:55:25 +0200 Subject: [PATCH] Birthday module: dusting --- modules/birthday.py | 14 ++++++++------ modules/birthday.xml | 5 ----- 2 files changed, 8 insertions(+), 11 deletions(-) delete mode 100644 modules/birthday.xml diff --git a/modules/birthday.py b/modules/birthday.py index 74013e0..9bb172d 100644 --- a/modules/birthday.py +++ b/modules/birthday.py @@ -10,16 +10,20 @@ from xmlparser.node import ModuleState nemubotversion = 3.3 def load(context): + from hooks import Hook + add_hook("cmd_hook", Hook(cmd_anniv, "anniv")) + add_hook("cmd_hook", Hook(cmd_age, "age")) + global DATAS DATAS.setIndex("name", "birthday") -def help_tiny (): +def help_tiny(): """Line inserted in the response to the command !help""" return "People birthdays and ages" -def help_full (): +def help_full(): return "!anniv /who/: gives the remaining time before the anniversary of /who/\n!age /who/: gives the age of /who/\nIf /who/ is not given, gives the remaining time before your anniversary.\n\n To set yout birthday, say it to nemubot :)" @@ -83,8 +87,7 @@ def cmd_age(msg): return True def parseask(msg): - msgl = msg.content.lower () - if re.match("^.*(date de naissance|birthday|geburtstag|née? |nee? le|born on).*$", msgl) is not None: + if re.match("^.*(date de naissance|birthday|geburtstag|née? |nee? le|born on).*$", msgl, re.I) is not None: try: extDate = msg.extractDate() if extDate is None or extDate.year > datetime.now().year: @@ -107,5 +110,4 @@ def parseask(msg): msg.channel, msg.nick) except: - return Response(msg.sender, "ta date de naissance ne paraît pas valide...", - msg.channel, msg.nick) + raise IRCException("ta date de naissance ne paraît pas valide.") diff --git a/modules/birthday.xml b/modules/birthday.xml deleted file mode 100644 index e03a15b..0000000 --- a/modules/birthday.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - -