From c9faa8bb7ac9a0f7811e5213b1622e2e638820a3 Mon Sep 17 00:00:00 2001 From: skizzerz Date: Mon, 15 May 2017 20:35:47 -0500 Subject: [PATCH] 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). --- src/users.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/users.py b/src/users.py index 9ab3d10..29ee8b7 100644 --- a/src/users.py +++ b/src/users.py @@ -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)