Skip to content

Commit

Permalink
🐛 Fix type error in api_ran_time
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreomeow committed Oct 14, 2022
1 parent 3d19631 commit 05c2fbb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions api_ran_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from abc import ABC
from random import randrange
from typing import Dict, List
from typing import Dict, List, Optional

import requests

Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(self, client_info: Dict):
raise ValueError("无法获取 token!")

def init_cron(self):
self.cron: List[Dict] = list(
self.cron = list(
filter(
lambda x: not x.get("isDisabled", 1)
and x.get("command", "").find("Oreomeow_checkinpanel_master") != -1,
Expand All @@ -107,17 +107,24 @@ def shuffle_cron(self):
)


def get_client():
def get_client() -> Optional[QLClient]:
env_type = get_env_int()
if env_type in [5, 6]:
check_data = get_data()
return QLClient(check_data.get("RANDOM", [{}])[0])
return None


try:
get_client().run()
send("随机定时", "处于启动状态的任务定时修改成功!")
except ValueError as e:
send("随机定时", f"配置错误,{e},请检查你的配置文件!")
except AttributeError:
send("随机定时", "你的系统不支持运行随机定时!")
def main():
try:
if client := get_client():
client.run()
send("随机定时", "处于启动状态的任务定时修改成功!")
else:
send("随机定时", "你的系统不支持运行随机定时!")
except ValueError as e:
send("随机定时", f"配置错误,{e},请检查你的配置文件!")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion utils_ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import requests

__version__ = "20221014-4-033"
__version__ = "20221014-4-043"
ONLINE_VERSION = ""
ver_re = re.compile("__version__ = .(\\d+-\\d+-...).")

Expand Down

0 comments on commit 05c2fbb

Please sign in to comment.