make stuff prettier i guess

This commit is contained in:
Vgr E. Barry 2017-08-21 14:16:04 -04:00
parent f766c76076
commit 5d14327380
3 changed files with 16 additions and 12 deletions

View File

@ -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):

View File

@ -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

View File

@ -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