Changing sender to nick in modules

This commit is contained in:
Némunaire 2012-07-23 12:07:26 +02:00
commit 14a963871f
12 changed files with 103 additions and 101 deletions

View file

@ -23,12 +23,12 @@ 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 :)"
def findName(msg):
def findName(msg):
if len(msg.cmd) < 2 or msg.cmd[1].lower() == "moi" or msg.cmd[1].lower() == "me":
name = msg.sender.lower()
name = msg.nick.lower()
else:
name = msg.cmd[1].lower()
matches = []
if name in DATAS.index:
@ -38,7 +38,7 @@ def findName(msg):
if k.find (name) == 0:
matches.append (k)
return (matches, name)
def parseanswer(msg):
if msg.cmd[0] == "anniv":
@ -56,7 +56,7 @@ def parseanswer(msg):
msg.send_chn (msg.countdown_format (tyd, "Il reste %s avant l'anniversaire de %s !" % ("%s", name), ""))
else:
msg.send_chn ("%s: désolé, je ne connais pas la date d'anniversaire de %s. Quand est-il né ?"%(msg.sender, name))
msg.send_chn ("%s: désolé, je ne connais pas la date d'anniversaire de %s. Quand est-il né ?"%(msg.nick, name))
return True
elif msg.cmd[0] == "age":
(matches, name) = findName(msg)
@ -66,7 +66,7 @@ def parseanswer(msg):
msg.send_chn (msg.countdown_format (d, "", "%s a %s." % (n, "%s")))
else:
msg.send_chn ("%s: désolé, je ne connais pas l'âge de %s. Quand est-il né ?"%(msg.sender, name))
msg.send_chn ("%s: désolé, je ne connais pas l'âge de %s. Quand est-il né ?"%(msg.nick, name))
return True
else:
return False
@ -77,19 +77,19 @@ def parseask(msg):
try:
extDate = msg.extractDate ()
if extDate is None:
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.sender))
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.nick))
else:
if msg.sender.lower() in DATAS.index:
DATAS.index[msg.sender.lower()] = extDate
if msg.nick.lower() in DATAS.index:
DATAS.index[msg.nick.lower()] = extDate
else:
ms = ModuleState("birthday")
ms.setAttribute("name", msg.sender.lower())
ms.setAttribute("name", msg.nick.lower())
ms.setAttribute("born", extDate)
DATAS.addChild(ms)
msg.send_chn ("%s: ok, c'est noté, ta date de naissance est le %s" % (msg.sender, extDate.strftime("%A %d %B %Y à %H:%M")))
msg.send_chn ("%s: ok, c'est noté, ta date de naissance est le %s" % (msg.nick, extDate.strftime("%A %d %B %Y à %H:%M")))
save()
except:
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.sender))
msg.send_chn ("%s: ta date de naissance ne paraît pas valide..." % (msg.nick))
return True
return False