diff --git a/modules/alias.py b/modules/alias.py index 5053783..5aae6bb 100644 --- a/modules/alias.py +++ b/modules/alias.py @@ -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) diff --git a/modules/birthday.py b/modules/birthday.py index cb850ac..7a9cdaa 100644 --- a/modules/birthday.py +++ b/modules/birthday.py @@ -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.") diff --git a/modules/events.py b/modules/events.py index a35c28b..0cc5a44 100644 --- a/modules/events.py +++ b/modules/events.py @@ -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) diff --git a/modules/mapquest.py b/modules/mapquest.py index 55b87c0..1caa41c 100644 --- a/modules/mapquest.py +++ b/modules/mapquest.py @@ -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)): diff --git a/modules/reddit.py b/modules/reddit.py index 7d481b7..31f566c 100644 --- a/modules/reddit.py +++ b/modules/reddit.py @@ -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 diff --git a/modules/rnd.py b/modules/rnd.py index 5329b06..6044bd4 100644 --- a/modules/rnd.py +++ b/modules/rnd.py @@ -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") diff --git a/modules/sms.py b/modules/sms.py index 3a9727f..61e63d6 100644 --- a/modules/sms.py +++ b/modules/sms.py @@ -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[0-9]{7,})", re.IGNORECASE) apikey_ask = re.compile(r"(clef|key|password|mot de passe?)\s+(?:est|is)?\s+(?P[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) diff --git a/modules/spell/__init__.py b/modules/spell/__init__.py index a70b016..c15f5fc 100644 --- a/modules/spell/__init__.py +++ b/modules/spell/__init__.py @@ -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 diff --git a/modules/virtualradar.py b/modules/virtualradar.py index ffd5a67..d7448ce 100644 --- a/modules/virtualradar.py +++ b/modules/virtualradar.py @@ -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: diff --git a/modules/weather.py b/modules/weather.py index 8b3540e..8c9ca0e 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -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) diff --git a/modules/whois.py b/modules/whois.py index fb6d250..ae27ccc 100644 --- a/modules/whois.py +++ b/modules/whois.py @@ -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) diff --git a/modules/worldcup.py b/modules/worldcup.py index 7b4f53d..ff3e0c4 100644 --- a/modules/worldcup.py +++ b/modules/worldcup.py @@ -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() diff --git a/nemubot/bot.py b/nemubot/bot.py index aa1cb3e..6327afe 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -92,7 +92,7 @@ class Bot(threading.Thread): def in_echo(msg): from nemubot.message import Text - return Text(msg.nick + ": " + " ".join(msg.args), to=msg.to_response) + return Text(msg.frm + ": " + " ".join(msg.args), to=msg.to_response) self.treater.hm.add_hook(nemubot.hooks.Command(in_echo, "echo"), "in", "Command") def _help_msg(msg): diff --git a/nemubot/channel.py b/nemubot/channel.py index a070131..835c22f 100644 --- a/nemubot/channel.py +++ b/nemubot/channel.py @@ -52,11 +52,11 @@ class Channel: elif cmd == "MODE": self.mode(msg) elif cmd == "JOIN": - self.join(msg.nick) + self.join(msg.frm) elif cmd == "NICK": - self.nick(msg.nick, msg.text) + self.nick(msg.frm, msg.text) elif cmd == "PART" or cmd == "QUIT": - self.part(msg.nick) + self.part(msg.frm) elif cmd == "TOPIC": self.topic = self.text @@ -120,17 +120,17 @@ class Channel: else: self.password = msg.text[1] elif msg.text[0] == "+o": - self.people[msg.nick] |= 4 + self.people[msg.frm] |= 4 elif msg.text[0] == "-o": - self.people[msg.nick] &= ~4 + self.people[msg.frm] &= ~4 elif msg.text[0] == "+h": - self.people[msg.nick] |= 2 + self.people[msg.frm] |= 2 elif msg.text[0] == "-h": - self.people[msg.nick] &= ~2 + self.people[msg.frm] &= ~2 elif msg.text[0] == "+v": - self.people[msg.nick] |= 1 + self.people[msg.frm] |= 1 elif msg.text[0] == "-v": - self.people[msg.nick] &= ~1 + self.people[msg.frm] &= ~1 def parse332(self, msg): """Parse RPL_TOPIC message diff --git a/nemubot/message/abstract.py b/nemubot/message/abstract.py index 6ee43d5..3af0511 100644 --- a/nemubot/message/abstract.py +++ b/nemubot/message/abstract.py @@ -59,12 +59,6 @@ class Abstract: else: return None - @property - def nick(self): - # TODO: this is for legacy modules - return self.frm - - def accept(self, visitor): visitor.visit(self) diff --git a/nemubot/server/IRC.py b/nemubot/server/IRC.py index 7469abc..7adc484 100644 --- a/nemubot/server/IRC.py +++ b/nemubot/server/IRC.py @@ -174,10 +174,10 @@ class _IRC: for chname in msg.params[0].split(b","): if chname in self.channels: - if msg.nick == self.nick: + if msg.frm == self.nick: del self.channels[chname] - elif msg.nick in self.channels[chname].people: - del self.channels[chname].people[msg.nick] + elif msg.frm in self.channels[chname].people: + del self.channels[chname].people[msg.frm] self.hookscmd["PART"] = _on_part # Respond to 331/RPL_NOTOPIC,332/RPL_TOPIC,TOPIC def _on_topic(msg): @@ -227,7 +227,7 @@ class _IRC: else: res = "ERRMSG Unknown or unimplemented CTCP request" if res is not None: - self.write("NOTICE %s :\x01%s\x01" % (msg.nick, res)) + self.write("NOTICE %s :\x01%s\x01" % (msg.frm, res)) self.hookscmd["PRIVMSG"] = _on_ctcp