Convert Client.nick into property

to add previous nick to .nick_history on set
This commit is contained in:
Thor77 2017-07-24 14:38:48 +02:00
parent a084101ced
commit 088d905196
1 changed files with 13 additions and 1 deletions

View File

@ -92,7 +92,7 @@ class Client(object):
''' '''
# public # public
self.identifier = identifier self.identifier = identifier
self.nick = nick self._nick = nick
self.nick_history = set() self.nick_history = set()
self.connected = 0 self.connected = 0
self.onlinetime = datetime.timedelta() self.onlinetime = datetime.timedelta()
@ -104,6 +104,18 @@ class Client(object):
# private # private
self._last_connect = 0 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): def connect(self, timestamp):
''' '''
Connect client at `timestamp` Connect client at `timestamp`