支持企微应用通知和第Server、Anpush、PushPlus等第三方推送。按要求修改插件名称

This commit is contained in:
ramen
2024-11-13 03:35:07 +08:00
parent 61dd0ef918
commit c9cc458dca
4 changed files with 271 additions and 214 deletions

View File

@@ -7,9 +7,6 @@ from typing import Dict, Any
from Crypto import Random
from Crypto.Cipher import AES
script_dir = os.path.dirname(os.path.abspath(__file__))
settings_file = os.path.join(script_dir, 'settings.json')
def bytes_to_key(data: bytes, salt: bytes, output=48) -> bytes:
# 兼容v2 将bytes_to_key和encrypt导入
@@ -98,7 +95,7 @@ class PyCookieCloud:
return md5.hexdigest()[:16]
@staticmethod
def load_cookie_lifetime(): # 返回时间戳 单位秒
def load_cookie_lifetime(settings_file: str = None): # 返回时间戳 单位秒
if os.path.exists(settings_file):
with open(settings_file, 'r') as file:
settings = json.load(file)
@@ -107,13 +104,18 @@ class PyCookieCloud:
return 0
@staticmethod
def save_cookie_lifetime(cookie_lifetime): # 传入时间戳 单位秒
def save_cookie_lifetime(settings_file, cookie_lifetime): # 传入时间戳 单位秒
with open(settings_file, 'w') as file:
json.dump({'_cookie_lifetime': cookie_lifetime}, file)
@staticmethod
def increase_cookie_lifetime(seconds: int):
current_lifetime = PyCookieCloud.load_cookie_lifetime()
def increase_cookie_lifetime(settings_file, seconds: int):
if os.path.exists(settings_file):
with open(settings_file, 'r') as file:
settings = json.load(file)
current_lifetime = settings.get('_cookie_lifetime', 0)
else:
current_lifetime = 0
new_lifetime = current_lifetime + seconds
# 保存新的 _cookie_lifetime
PyCookieCloud.save_cookie_lifetime(new_lifetime)
PyCookieCloud.save_cookie_lifetime(settings_file, new_lifetime)