Initial restarted commit
This commit is contained in:
53
HelperLogInOut.py
Normal file
53
HelperLogInOut.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# 登录·登出实现
|
||||
# 一般作为模块使用,但也可以作为 CLI 程序运行以强制登出账号。
|
||||
|
||||
import json
|
||||
import time
|
||||
from loguru import logger
|
||||
|
||||
from Static_Settings import *
|
||||
from API_TitleServer import apiSDGB
|
||||
|
||||
def apiLogin(timestamp:int, userId:int) -> dict:
|
||||
'''登录,返回服务器给的 Json 的 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))
|
||||
logger.info("登录:结果:"+ str(login_result))
|
||||
return login_result
|
||||
|
||||
def apiLogout(timestamp:int, userId:int) -> dict:
|
||||
'''登出,返回 Json 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))
|
||||
logger.info("登出:结果:"+ str(logout_result))
|
||||
return logout_result
|
||||
|
||||
|
||||
def generateTimestamp() -> int:
|
||||
'''生成时间戳'''
|
||||
timestamp = int(time.time()) - 60
|
||||
logger.info(f"生成时间戳: {timestamp}")
|
||||
return timestamp
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("强制登出 CLI")
|
||||
uid = testUid
|
||||
timestamp = input("Timestamp: ")
|
||||
apiLogout(int(timestamp), int(uid))
|
||||
Reference in New Issue
Block a user