Remove legacy msg.nick
This commit is contained in:
parent
694c54a6bc
commit
fde459c3ff
16 changed files with 49 additions and 55 deletions
|
|
@ -185,7 +185,7 @@ def cmd_listvars(msg):
|
|||
def cmd_set(msg):
|
||||
if len(msg.args) < 2:
|
||||
raise IMException("!set take two args: the key and the value.")
|
||||
set_variable(msg.args[0], " ".join(msg.args[1:]), msg.nick)
|
||||
set_variable(msg.args[0], " ".join(msg.args[1:]), msg.frm)
|
||||
return Response("Variable $%s successfully defined." % msg.args[0],
|
||||
channel=msg.channel)
|
||||
|
||||
|
|
@ -222,13 +222,13 @@ def cmd_alias(msg):
|
|||
|
||||
if alias.cmd in context.data.getNode("aliases").index:
|
||||
return Response("%s corresponds to %s" % (alias.cmd, context.data.getNode("aliases").index[alias.cmd]["origin"]),
|
||||
channel=msg.channel, nick=msg.nick)
|
||||
channel=msg.channel, nick=msg.frm)
|
||||
|
||||
elif len(msg.args) > 1:
|
||||
create_alias(alias.cmd,
|
||||
" ".join(msg.args[1:]),
|
||||
channel=msg.channel,
|
||||
creator=msg.nick)
|
||||
creator=msg.frm)
|
||||
return Response("New alias %s successfully registered." % alias.cmd,
|
||||
channel=msg.channel)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def load(context):
|
|||
def findName(msg):
|
||||
if (not len(msg.args) or msg.args[0].lower() == "moi" or
|
||||
msg.args[0].lower() == "me"):
|
||||
name = msg.nick.lower()
|
||||
name = msg.frm.lower()
|
||||
else:
|
||||
name = msg.args[0].lower()
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ def cmd_anniv(msg):
|
|||
else:
|
||||
return Response("désolé, je ne connais pas la date d'anniversaire"
|
||||
" de %s. Quand est-il né ?" % name,
|
||||
msg.channel, msg.nick)
|
||||
msg.channel, msg.frm)
|
||||
|
||||
|
||||
@hook.command("age",
|
||||
|
|
@ -98,7 +98,7 @@ def cmd_age(msg):
|
|||
msg.channel)
|
||||
else:
|
||||
return Response("désolé, je ne connais pas l'âge de %s."
|
||||
" Quand est-il né ?" % name, msg.channel, msg.nick)
|
||||
" Quand est-il né ?" % name, msg.channel, msg.frm)
|
||||
return True
|
||||
|
||||
|
||||
|
|
@ -113,11 +113,11 @@ def parseask(msg):
|
|||
if extDate is None or extDate.year > datetime.now().year:
|
||||
return Response("la date de naissance ne paraît pas valide...",
|
||||
msg.channel,
|
||||
msg.nick)
|
||||
msg.frm)
|
||||
else:
|
||||
nick = res.group(1)
|
||||
if nick == "my" or nick == "I" or nick == "i" or nick == "je" or nick == "mon" or nick == "ma":
|
||||
nick = msg.nick
|
||||
nick = msg.frm
|
||||
if nick.lower() in context.data.index:
|
||||
context.data.index[nick.lower()]["born"] = extDate
|
||||
else:
|
||||
|
|
@ -129,6 +129,6 @@ def parseask(msg):
|
|||
return Response("ok, c'est noté, %s est né le %s"
|
||||
% (nick, extDate.strftime("%A %d %B %Y à %H:%M")),
|
||||
msg.channel,
|
||||
msg.nick)
|
||||
msg.frm)
|
||||
except:
|
||||
raise IMException("la date de naissance ne paraît pas valide.")
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def start_countdown(msg):
|
|||
strnd = ModuleState("strend")
|
||||
strnd["server"] = msg.server
|
||||
strnd["channel"] = msg.channel
|
||||
strnd["proprio"] = msg.nick
|
||||
strnd["proprio"] = msg.frm
|
||||
strnd["start"] = msg.date
|
||||
strnd["name"] = msg.args[0]
|
||||
context.data.addChild(strnd)
|
||||
|
|
@ -145,17 +145,17 @@ def end_countdown(msg):
|
|||
raise IMException("quel événement terminer ?")
|
||||
|
||||
if msg.args[0] in context.data.index:
|
||||
if context.data.index[msg.args[0]]["proprio"] == msg.nick or (msg.cmd == "forceend" and msg.frm_owner):
|
||||
if context.data.index[msg.args[0]]["proprio"] == msg.frm or (msg.cmd == "forceend" and msg.frm_owner):
|
||||
duration = countdown(msg.date - context.data.index[msg.args[0]].getDate("start"))
|
||||
context.del_event(context.data.index[msg.args[0]]["_id"])
|
||||
context.data.delChild(context.data.index[msg.args[0]])
|
||||
context.save()
|
||||
return Response("%s a duré %s." % (msg.args[0], duration),
|
||||
channel=msg.channel, nick=msg.nick)
|
||||
channel=msg.channel, nick=msg.frm)
|
||||
else:
|
||||
raise IMException("Vous ne pouvez pas terminer le compteur %s, créé par %s." % (msg.args[0], context.data.index[msg.args[0]]["proprio"]))
|
||||
else:
|
||||
return Response("%s n'est pas un compteur connu."% (msg.args[0]), channel=msg.channel, nick=msg.nick)
|
||||
return Response("%s n'est pas un compteur connu."% (msg.args[0]), channel=msg.channel, nick=msg.frm)
|
||||
|
||||
|
||||
@hook.command("eventslist")
|
||||
|
|
@ -180,7 +180,7 @@ def parseanswer(msg):
|
|||
|
||||
# Avoid message starting by ! which can be interpreted as command by other bots
|
||||
if msg.cmd[0] == "!":
|
||||
res.nick = msg.nick
|
||||
res.nick = msg.frm
|
||||
|
||||
if context.data.index[msg.cmd].name == "strend":
|
||||
if context.data.index[msg.cmd].hasAttribute("end"):
|
||||
|
|
@ -223,7 +223,7 @@ def parseask(msg):
|
|||
evt = ModuleState("event")
|
||||
evt["server"] = msg.server
|
||||
evt["channel"] = msg.channel
|
||||
evt["proprio"] = msg.nick
|
||||
evt["proprio"] = msg.frm
|
||||
evt["name"] = name.group(1)
|
||||
evt["start"] = extDate
|
||||
evt["msg_after"] = msg_after
|
||||
|
|
@ -237,7 +237,7 @@ def parseask(msg):
|
|||
evt = ModuleState("event")
|
||||
evt["server"] = msg.server
|
||||
evt["channel"] = msg.channel
|
||||
evt["proprio"] = msg.nick
|
||||
evt["proprio"] = msg.frm
|
||||
evt["name"] = name.group(1)
|
||||
evt["msg_before"] = texts.group (2)
|
||||
context.data.addChild(evt)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def cmd_geocode(msg):
|
|||
if not len(msg.args):
|
||||
raise IMException("indicate a name")
|
||||
|
||||
res = Response(channel=msg.channel, nick=msg.nick,
|
||||
res = Response(channel=msg.channel, nick=msg.frm,
|
||||
nomore="No more geocode", count=" (%s more geocode)")
|
||||
|
||||
for loc in geocode(' '.join(msg.args)):
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def cmd_subreddit(msg):
|
|||
channel=msg.channel))
|
||||
else:
|
||||
all_res.append(Response("%s is not a valid subreddit" % osub,
|
||||
channel=msg.channel, nick=msg.nick))
|
||||
channel=msg.channel, nick=msg.frm))
|
||||
|
||||
return all_res
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def cmd_choice(msg):
|
|||
|
||||
return Response(random.choice(msg.args),
|
||||
channel=msg.channel,
|
||||
nick=msg.nick)
|
||||
nick=msg.frm)
|
||||
|
||||
|
||||
@hook.command("choicecmd")
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ def cmd_sms(msg):
|
|||
fails.append( "%s: %s" % (u, test) )
|
||||
|
||||
if len(fails) > 0:
|
||||
return Response("quelque chose ne s'est pas bien passé durant l'envoi du SMS : " + ", ".join(fails), msg.channel, msg.nick)
|
||||
return Response("quelque chose ne s'est pas bien passé durant l'envoi du SMS : " + ", ".join(fails), msg.channel, msg.frm)
|
||||
else:
|
||||
return Response("le SMS a bien été envoyé", msg.channel, msg.nick)
|
||||
return Response("le SMS a bien été envoyé", msg.channel, msg.frm)
|
||||
|
||||
apiuser_ask = re.compile(r"(utilisateur|user|numéro|numero|compte|abonne|abone|abonné|account)\s+(est|is)\s+(?P<user>[0-9]{7,})", re.IGNORECASE)
|
||||
apikey_ask = re.compile(r"(clef|key|password|mot de passe?)\s+(?:est|is)?\s+(?P<key>[a-zA-Z0-9]{10,})", re.IGNORECASE)
|
||||
|
|
@ -94,18 +94,18 @@ def parseask(msg):
|
|||
test = send_sms("nemubot", apiuser, apikey,
|
||||
"Vous avez enregistré vos codes d'authentification dans nemubot, félicitation !")
|
||||
if test is not None:
|
||||
return Response("je n'ai pas pu enregistrer tes identifiants : %s" % test, msg.channel, msg.nick)
|
||||
return Response("je n'ai pas pu enregistrer tes identifiants : %s" % test, msg.channel, msg.frm)
|
||||
|
||||
if msg.nick in context.data.index:
|
||||
context.data.index[msg.nick]["user"] = apiuser
|
||||
context.data.index[msg.nick]["key"] = apikey
|
||||
if msg.frm in context.data.index:
|
||||
context.data.index[msg.frm]["user"] = apiuser
|
||||
context.data.index[msg.frm]["key"] = apikey
|
||||
else:
|
||||
ms = ModuleState("phone")
|
||||
ms.setAttribute("name", msg.nick)
|
||||
ms.setAttribute("name", msg.frm)
|
||||
ms.setAttribute("user", apiuser)
|
||||
ms.setAttribute("key", apikey)
|
||||
ms.setAttribute("lastuse", 0)
|
||||
context.data.addChild(ms)
|
||||
context.save()
|
||||
return Response("ok, c'est noté. Je t'ai envoyé un SMS pour tester ;)",
|
||||
msg.channel, msg.nick)
|
||||
msg.channel, msg.frm)
|
||||
|
|
|
|||
|
|
@ -64,15 +64,15 @@ def cmd_spell(msg):
|
|||
raise IMException("Je n'ai pas le dictionnaire `%s' :(" % lang)
|
||||
|
||||
if r == True:
|
||||
add_score(msg.nick, "correct")
|
||||
add_score(msg.frm, "correct")
|
||||
res.append_message("l'orthographe de `%s' est correcte" % word)
|
||||
|
||||
elif len(r) > 0:
|
||||
add_score(msg.nick, "bad")
|
||||
add_score(msg.frm, "bad")
|
||||
res.append_message(r, title="suggestions pour `%s'" % word)
|
||||
|
||||
else:
|
||||
add_score(msg.nick, "bad")
|
||||
add_score(msg.frm, "bad")
|
||||
res.append_message("aucune suggestion pour `%s'" % word)
|
||||
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def cmd_flight(msg):
|
|||
if not len(msg.args):
|
||||
raise IMException("please indicate a flight")
|
||||
|
||||
res = Response(channel=msg.channel, nick=msg.nick,
|
||||
res = Response(channel=msg.channel, nick=msg.frm,
|
||||
nomore="No more flights", count=" (%s more flights)")
|
||||
|
||||
for param in msg.args:
|
||||
|
|
|
|||
|
|
@ -220,4 +220,4 @@ def parseask(msg):
|
|||
context.data.addChild(ms)
|
||||
context.save()
|
||||
return Response("ok, j'ai bien noté les coordonnées de %s" % res.group("city"),
|
||||
msg.channel, msg.nick)
|
||||
msg.channel, msg.frm)
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ def parseask(msg):
|
|||
nick = res.group(1)
|
||||
login = res.group(3)
|
||||
if nick == "my" or nick == "I" or nick == "i" or nick == "je" or nick == "mon" or nick == "ma":
|
||||
nick = msg.nick
|
||||
nick = msg.frm
|
||||
if nick in context.data.getNode("aliases").index:
|
||||
context.data.getNode("aliases").index[nick]["to"] = login
|
||||
else:
|
||||
|
|
@ -164,4 +164,4 @@ def parseask(msg):
|
|||
return Response("ok, c'est noté, %s est %s"
|
||||
% (nick, login),
|
||||
channel=msg.channel,
|
||||
nick=msg.nick)
|
||||
nick=msg.frm)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def start_watch(msg):
|
|||
w = ModuleState("watch")
|
||||
w["server"] = msg.server
|
||||
w["channel"] = msg.channel
|
||||
w["proprio"] = msg.nick
|
||||
w["proprio"] = msg.frm
|
||||
w["start"] = datetime.now(timezone.utc)
|
||||
context.data.addChild(w)
|
||||
context.save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue