云函数判断
This commit is contained in:
parent
edb0f54630
commit
148e7e6025
@ -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
|
||||
|
3
index.py
3
index.py
@ -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("云函数多用户测试支持!")
|
||||
|
Loading…
Reference in New Issue
Block a user