50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
import rapidjson as json
|
|
import time
|
|
from loguru import logger
|
|
import random
|
|
|
|
from Config import *
|
|
from API_TitleServer import apiSDGB
|
|
|
|
def apiLogin(timestamp:int, userId:int, noLog:bool=False) -> dict:
|
|
data = json.dumps({
|
|
"userId": userId,
|
|
"accessCode": "",
|
|
"regionId": regionId,
|
|
"placeId": placeId,
|
|
"clientId": clientId,
|
|
"dateTime": timestamp,
|
|
"isContinue": False,
|
|
"genericFlag": 0,
|
|
})
|
|
login_result = json.loads(apiSDGB(data, "UserLoginApi", userId, noLog))
|
|
if not noLog:
|
|
logger.info("登录:结果:"+ str(login_result))
|
|
return login_result
|
|
|
|
def apiLogout(timestamp:int, userId:int, noLog:bool=False) -> dict:
|
|
data = json.dumps({
|
|
"userId": userId,
|
|
"accessCode": "",
|
|
"regionId": regionId,
|
|
"placeId": placeId,
|
|
"clientId": clientId,
|
|
"dateTime": timestamp,
|
|
"type": 1
|
|
})
|
|
logout_result = json.loads(apiSDGB(data, "UserLogoutApi", userId, noLog))
|
|
if not noLog:
|
|
logger.info("登出:结果:"+ str(logout_result))
|
|
return logout_result
|
|
|
|
def generateTimestampLegacy() -> int:
|
|
timestamp = int(time.time()) - 60
|
|
logger.info(f"生成时间戳: {timestamp}")
|
|
return timestamp
|
|
|
|
def generateTimestamp() -> int:
|
|
timestamp = int(time.mktime(time.strptime(time.strftime("%Y-%m-%d 10:00:00"), "%Y-%m-%d %H:%M:%S"))) + random.randint(-600, 600)
|
|
logger.info(f"生成时间戳: {timestamp}")
|
|
logger.info(f"此时间戳对应的时间为: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp))}")
|
|
return timestamp
|