From 677abae25785ba4a81343663077d366a3ab854c6 Mon Sep 17 00:00:00 2001 From: Nyo Date: Mon, 1 Aug 2016 20:38:26 +0200 Subject: [PATCH] .BANCHO. Add timezones --- constants/serverPackets.py | 2 +- events/loginEvent.py | 4 +++- objects/osuToken.py | 3 ++- objects/tokenList.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/constants/serverPackets.py b/constants/serverPackets.py index 5bc9d40..b5a1448 100644 --- a/constants/serverPackets.py +++ b/constants/serverPackets.py @@ -94,7 +94,7 @@ def userPanel(userID, force = False): # Get user data username = userToken.username - timezone = 24 # TODO: Timezone + timezone = 24+userToken.timeOffset # TODO: Timezone country = userToken.country gameRank = userToken.gameRank latitude = userToken.getLatitude() diff --git a/events/loginEvent.py b/events/loginEvent.py index e0fe0b9..6138c9c 100644 --- a/events/loginEvent.py +++ b/events/loginEvent.py @@ -48,6 +48,8 @@ def handle(tornadoRequest): # [4] disk ID splitData = loginData[2].split("|") osuVersion = splitData[0] + timeOffset = int(splitData[1]) + print(str(timeOffset)) clientData = splitData[3].split(":")[:5] if len(clientData) < 4: raise exceptions.forceUpdateException() @@ -104,7 +106,7 @@ def handle(tornadoRequest): # Delete old tokens for that user and generate a new one glob.tokens.deleteOldTokens(userID) - responseToken = glob.tokens.addToken(userID, requestIP) + responseToken = glob.tokens.addToken(userID, requestIP, timeOffset=timeOffset) responseTokenString = responseToken.token # Check restricted mode (and eventually send message) diff --git a/objects/osuToken.py b/objects/osuToken.py index e022477..4f8b23f 100644 --- a/objects/osuToken.py +++ b/objects/osuToken.py @@ -35,7 +35,7 @@ class token: """ - def __init__(self, __userID, token = None, ip = "", irc = False): + def __init__(self, __userID, token = None, ip = "", irc = False, timeOffset = 0): """ Create a token object and set userID and token @@ -55,6 +55,7 @@ class token: self.restricted = userHelper.isRestricted(self.userID) self.loginTime = int(time.time()) self.pingTime = self.loginTime + self.timeOffset = timeOffset self.lock = threading.Lock() # Sync primitive # Default variables diff --git a/objects/tokenList.py b/objects/tokenList.py index 6239cf4..8778011 100644 --- a/objects/tokenList.py +++ b/objects/tokenList.py @@ -19,7 +19,7 @@ class tokenList: """ self.tokens = {} - def addToken(self, userID, ip = "", irc = False): + def addToken(self, userID, ip = "", irc = False, timeOffset=0): """ Add a token object to tokens list @@ -28,7 +28,7 @@ class tokenList: return -- token object """ - newToken = osuToken.token(userID, ip=ip, irc=irc) + newToken = osuToken.token(userID, ip=ip, irc=irc, timeOffset=timeOffset) self.tokens[newToken.token] = newToken return newToken