make stuff prettier i guess
This commit is contained in:
parent
f766c76076
commit
5d14327380
@ -262,7 +262,7 @@ class Channel(IRCContext):
|
|||||||
if not self.modes[mode]:
|
if not self.modes[mode]:
|
||||||
del self.modes[mode]
|
del self.modes[mode]
|
||||||
del user.channels[self]
|
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 = Event("cleanup_user", {})
|
||||||
event.dispatch(var, user)
|
event.dispatch(var, user)
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class Channel(IRCContext):
|
|||||||
self.modes.clear()
|
self.modes.clear()
|
||||||
self.state = _States.Cleared
|
self.state = _States.Cleared
|
||||||
self.timestamp = None
|
self.timestamp = None
|
||||||
del _channels[self.name]
|
del _channels[lower(self.name)]
|
||||||
|
|
||||||
class FakeChannel(Channel):
|
class FakeChannel(Channel):
|
||||||
|
|
||||||
|
@ -17,7 +17,9 @@ def _get_targets(var, pl, nick):
|
|||||||
|
|
||||||
var - settings module
|
var - settings module
|
||||||
pl - list of alive players
|
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):
|
for index, user in enumerate(var.ALL_PLAYERS):
|
||||||
if user.nick == nick: # FIXME
|
if user.nick == nick: # FIXME
|
||||||
break
|
break
|
||||||
|
20
src/users.py
20
src/users.py
@ -209,15 +209,6 @@ class User(IRCContext):
|
|||||||
|
|
||||||
is_user = True
|
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):
|
def __new__(cls, cli, nick, ident, host, realname, account):
|
||||||
self = super().__new__(cls)
|
self = super().__new__(cls)
|
||||||
super(__class__, self).__init__(nick, cli)
|
super(__class__, self).__init__(nick, cli)
|
||||||
@ -309,6 +300,17 @@ class User(IRCContext):
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self._compare(other, __class__, "nick", "ident", "host", "realname", "account")
|
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):
|
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))
|
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
|
if temp is not self: # If everything is already lowercase, we'll get back the same instance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user