From 2d80ba68043421d11b6543906dc505bee3a4deab Mon Sep 17 00:00:00 2001 From: Thor77 Date: Thu, 27 Oct 2016 00:08:28 +0200 Subject: [PATCH] Add action-group to re_dis_connect. Used to not rely on position in message for correct action-parsing. --- tsstats/log.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tsstats/log.py b/tsstats/log.py index bc5df4d..f3f4ce1 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -15,7 +15,7 @@ re_log_entry = re.compile('(?P\d{4}-\d\d-\d\d\ \d\d:\d\d:\d\d.\d+)' '\|\ *(?P\w+)\ *\|\ *(?P\w+)\ *' '\|\ *(?P\d+)\ *\|\ *(?P.*)') re_dis_connect = re.compile( - r"client (dis)?connected '(?P.*)'\(id:(?P\d+)\)") + r"client (?P(dis)?connected) '(?P.*)'\(id:(?P\d+)\)") re_disconnect_invoker = re.compile( r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg' ) @@ -135,9 +135,10 @@ def _parse_details(log_path, ident_map=None, clients=None, online_dc=True): nick, clid = match.group('nick'), match.group('clid') client = clients.setdefault(clid, Client(clid, nick)) client.nick = nick # set nick to display changes - if message.startswith('client connected'): + action = match.group('action') + if action == 'connected': client.connect(logdatetime) - elif message.startswith('client disconnected'): + elif action == 'disconnected': client.disconnect(logdatetime) if 'invokeruid' in message: re_disconnect_data = re_disconnect_invoker.findall(