diff --git a/src/channels.py b/src/channels.py index c139ae5..b173fab 100644 --- a/src/channels.py +++ b/src/channels.py @@ -262,7 +262,7 @@ class Channel(IRCContext): if not self.modes[mode]: del self.modes[mode] del user.channels[self] - if len(user.channels) == 0: + if not user.channels: # Only fire if the user left all channels event = Event("cleanup_user", {}) event.dispatch(var, user) @@ -273,7 +273,7 @@ class Channel(IRCContext): self.modes.clear() self.state = _States.Cleared self.timestamp = None - del _channels[self.name] + del _channels[lower(self.name)] class FakeChannel(Channel): diff --git a/src/roles/madscientist.py b/src/roles/madscientist.py index a9c3a1e..03b4d15 100644 --- a/src/roles/madscientist.py +++ b/src/roles/madscientist.py @@ -17,7 +17,9 @@ def _get_targets(var, pl, nick): var - settings module pl - list of alive players - nick - nick of the mad scientist""" + nick - nick of the mad scientist + + """ for index, user in enumerate(var.ALL_PLAYERS): if user.nick == nick: # FIXME break diff --git a/src/users.py b/src/users.py index 5708765..a7418d3 100644 --- a/src/users.py +++ b/src/users.py @@ -209,15 +209,6 @@ class User(IRCContext): is_user = True - # Things break a lot if user instances aren't unique for the same data set - # __new__ already returns an existing user instance if possible, but no need - # to run through that logic if we already know what instance is desired. - def __copy__(self): - return self - - def __deepcopy__(self, memo): - return self - def __new__(cls, cli, nick, ident, host, realname, account): self = super().__new__(cls) super(__class__, self).__init__(nick, cli) @@ -309,6 +300,17 @@ class User(IRCContext): def __eq__(self, other): return self._compare(other, __class__, "nick", "ident", "host", "realname", "account") + # User objects are not copyable - this is a deliberate design decision + # Therefore, those two functions here only return the object itself + # Even if we tried to create new instances, the logic in __new__ would + # just fetch back the same instance, so we save ourselves the trouble + + def __copy__(self): + return self + + def __deepcopy__(self, memo): + return self + def lower(self): temp = type(self)(self.client, lower(self.nick), lower(self.ident), lower(self.host, casemapping="ascii"), lower(self.realname), lower(self.account)) if temp is not self: # If everything is already lowercase, we'll get back the same instance