diff --git a/tsstats.py b/tsstats.py index cf7e3ae..14efbe3 100755 --- a/tsstats.py +++ b/tsstats.py @@ -24,13 +24,14 @@ def add_connect(clid, nick, logdatetime): clients[clid]['connected'] = True -def add_disconnect(clid, nick, logdatetime): +def add_disconnect(clid, nick, logdatetime, set_connected=True): check_client(clid, nick) connect = datetime.fromtimestamp(clients[clid]['last_connect']) delta = logdatetime - connect minutes = delta.seconds // 60 increase_onlinetime(clid, minutes) - clients[clid]['connected'] = False + if set_connected: + clients[clid]['connected'] = False def add_ban(clid, nick): @@ -101,7 +102,7 @@ for clid in clients: if 'connected' not in clients[clid]: clients[clid]['connected'] = False if clients[clid]['connected']: - add_disconnect(clid, clients[clid]['nick'], today) + add_disconnect(clid, clients[clid]['nick'], today, set_connected=False) # helper functions @@ -113,7 +114,7 @@ def desc(key): values[clid] = clients[clid][key] for clid in sorted(values, key=values.get, reverse=True): value = values[clid] - r.append((clients[clid]['nick'], value)) + r.append((clid, clients[clid]['nick'], value)) return r @@ -161,7 +162,7 @@ if len(onlinetime_desc) >= 1: output.append('

Onlinezeit

') output.append('') @@ -180,7 +185,7 @@ kicks_desc = desc('kicks') if len(kicks_desc) >= 1: output.append('

Kicks

') output.append('') @@ -188,7 +193,7 @@ pkicks_desc = desc('pkicks') if len(pkicks_desc) >= 1: output.append('

Gekickt worden

') output.append('') @@ -196,7 +201,7 @@ bans_desc = desc('bans') if len(bans_desc) >= 1: output.append('

Bans

') output.append('')