From c005e042cd5508e8c4d06ff1289add194652ff1b Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 13 Apr 2019 22:55:36 +0000 Subject: [PATCH] Avoid sending unnecessary nick commands This would get two Infobots in the same room stuck in a nick changing loop: The first updates its nick. The second receives a nick-event and updates its nick. The first receives a nick-event and updates its nick, and so on. --- infobot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infobot.py b/infobot.py index 5c50b6b..0b3d9fc 100644 --- a/infobot.py +++ b/infobot.py @@ -182,7 +182,9 @@ class InfoBot(yaboli.Bot): async def update_nick(self, room): users = await room.who() new_nick = self.format_nick(users) - await room.nick(new_nick) + + if room.session.nick != new_nick: + await room.nick(new_nick) async def on_connected(self, room): await self.update_nick(room)