Fix BotUser.with_host breaking things when called during registration

If with_host() is called before we fully know our ident and host, we'll
set the host but keep ident as None, which breaks everything down the
line. I could've fixed this in general in users._add, but that would
require more extensive changes than this patch (aka may break other
things).
This commit is contained in:
skizzerz 2017-05-15 20:35:47 -05:00
parent 68109a12ae
commit c9faa8bb7a

View File

@ -596,6 +596,10 @@ class BotUser(User): # TODO: change all the 'if x is Bot' for 'if isinstance(x,
def with_host(self, host):
"""Create a new bot instance with a new host."""
if self.ident is None and self.host is None:
# we don't have full details on our ident yet; setting host now causes bugs down the road since
# ident will subsequently not update. We'll pick up the new host whenever we finish setting ourselves up
return self
new = super().__new__(type(self), self.client, self.nick, self.ident, host, self.realname, self.account)
if new is not self:
new.modes = set(self.modes)