added event for when bot has it's nick changed.

This commit is contained in:
iou1name 2019-03-17 13:31:36 -04:00
parent f7cbd18f6e
commit 54ee7615b0

18
bot.py
View File

@ -312,7 +312,7 @@ class Fulvia(irc.IRCClient):
def left(self, channel, reason=""):
"""Called when the leaves a channel."""
"""Called when the bot leaves a channel."""
line = "-!- " + self.nickname + " " + "[" + self.username + "@"
line += self.host + "] has left " + channel + " [" + reason + "]"
self.log(channel, line)
@ -384,6 +384,20 @@ class Fulvia(irc.IRCClient):
self.channels.pop(channel)
def nickChanged(self, nick):
"""Called when the bot changes it's nickname."""
line = "-!- you are now known as " + nick
user = self.users.pop(self.nickname)
self.users[nick] = user
for key, channel in self.channels.items():
self.log(key, line)
channel.rename_user(self.nickname, nick)
user.nick = nick
self.nickname = nick
## Actions the bot observes other users doing in the channel.
## These will get called automatically.
@ -444,7 +458,7 @@ class Fulvia(irc.IRCClient):
def userRenamed(self, oldname, newname):
"""Called wehn the bot sees a user change their nickname."""
"""Called when the bot sees a user change their nickname."""
line = "-!- " + oldname + " is now known as " + newname
user = self.users.pop(oldname)