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.
This commit is contained in:
Joscha 2019-04-13 22:55:36 +00:00
parent 87628e1ff5
commit c005e042cd

View file

@ -182,6 +182,8 @@ class InfoBot(yaboli.Bot):
async def update_nick(self, room): async def update_nick(self, room):
users = await room.who() users = await room.who()
new_nick = self.format_nick(users) new_nick = self.format_nick(users)
if room.session.nick != new_nick:
await room.nick(new_nick) await room.nick(new_nick)
async def on_connected(self, room): async def on_connected(self, room):