add support for multiple connects with one identity

This commit is contained in:
Thor77 2015-06-22 16:20:20 +02:00
parent 8558a676a4
commit 28ded1fc9b
1 changed files with 6 additions and 5 deletions

View File

@ -65,7 +65,7 @@ class Client:
# public # public
self.identifier = identifier self.identifier = identifier
self.nick = None self.nick = None
self.connected = False self.connected = 0
self.onlinetime = datetime.timedelta() self.onlinetime = datetime.timedelta()
self.kicks = 0 self.kicks = 0
self.pkicks = 0 self.pkicks = 0
@ -79,7 +79,7 @@ class Client:
client connects at "timestamp" client connects at "timestamp"
''' '''
logging.debug('CONNECT {}'.format(str(self))) logging.debug('CONNECT {}'.format(str(self)))
self.connected = True self.connected += 1
self._last_connect = timestamp self._last_connect = timestamp
def disconnect(self, timestamp): def disconnect(self, timestamp):
@ -88,8 +88,9 @@ class Client:
''' '''
logging.debug('DISCONNECT {}'.format(str(self))) logging.debug('DISCONNECT {}'.format(str(self)))
if not self.connected: if not self.connected:
raise Exception('WTF did just happen?! A client disconnected before connecting!') logging.debug('^ disconnect before connect')
self.connected = False raise Exception('disconnect before connect!')
self.connected -= 1
session_time = timestamp - self._last_connect session_time = timestamp - self._last_connect
self.onlinetime += session_time self.onlinetime += session_time
@ -163,7 +164,7 @@ for log_file in log_files:
for line in log_lines: for line in log_lines:
parts = line.split('|') parts = line.split('|')
logdatetime = datetime.datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f') logdatetime = datetime.datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f')
data = parts[4].strip() data = '|'.join(parts[4:]).strip()
if data.startswith('client'): if data.startswith('client'):
nick, clid = re_dis_connect.findall(data)[0] nick, clid = re_dis_connect.findall(data)[0]
if clid in id_map: if clid in id_map: