云函数判断

This commit is contained in:
Womsxd 2022-04-26 15:59:28 +08:00
parent edb0f54630
commit 148e7e6025
No known key found for this signature in database
GPG Key ID: 0FE76418EE689B68
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,9 @@ import os
import json
from loghelper import log
# 这个字段现在还没找好塞什么地方好就先塞config这里了
serverless = False
# 是否启用config
enable = True
# 这里的内容会自动获取
@ -72,6 +75,9 @@ def load_config():
def save_config():
if not serverless:
log.info("云函数执行,无法保存")
return None
with open(config_Path, "r+") as f:
data = json.load(f)
data["mihoyobbs_Login_ticket"] = login_ticket
@ -87,6 +93,9 @@ def save_config():
def clear_cookies():
if not serverless:
log.info("云函数执行,无法保存")
return None
with open(config_Path, "r+") as f:
data = json.load(f)
data["enable_Config"] = False

View File

@ -2,9 +2,11 @@ import main
import push
import main_multi
from error import CookieError
from config import serverless
def main_handler(event: dict, context: dict):
serverless = True
try:
status_code, push_message = main.main()
except CookieError:
@ -15,6 +17,7 @@ def main_handler(event: dict, context: dict):
def main_handler_mulit(event: dict, context: dict):
serverless = True
# 多用户需要传递True表示自动执行不需要手动进行确认
main_multi.main_multi(True)
print("云函数多用户测试支持!")