Convert Client.nick into property
to add previous nick to .nick_history on set
This commit is contained in:
parent
a084101ced
commit
088d905196
|
@ -92,7 +92,7 @@ class Client(object):
|
|||
'''
|
||||
# public
|
||||
self.identifier = identifier
|
||||
self.nick = nick
|
||||
self._nick = nick
|
||||
self.nick_history = set()
|
||||
self.connected = 0
|
||||
self.onlinetime = datetime.timedelta()
|
||||
|
@ -104,6 +104,18 @@ class Client(object):
|
|||
# private
|
||||
self._last_connect = 0
|
||||
|
||||
@property
|
||||
def nick(self):
|
||||
return self._nick
|
||||
|
||||
@nick.setter
|
||||
def nick(self, new_nick):
|
||||
if self._nick and new_nick != self._nick:
|
||||
# add old nick to history
|
||||
self.nick_history.add(self._nick)
|
||||
# set new nick
|
||||
self._nick = new_nick
|
||||
|
||||
def connect(self, timestamp):
|
||||
'''
|
||||
Connect client at `timestamp`
|
||||
|
|
Loading…
Reference in New Issue