Skip to content

Commit

Permalink
chore: 添加多渠道同时推送 (#86)
Browse files Browse the repository at this point in the history
* chore: 添加多渠道同时推送
  • Loading branch information
Night-stars-1 committed Sep 21, 2023
1 parent dd8022a commit 42dfa56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from error import *
from loghelper import log


def checkin_game(game_name, game_module, game_print_name=""):
if config.config["games"]["cn"][game_name]["auto_checkin"]:
time.sleep(random.randint(2, 8))
Expand Down
35 changes: 18 additions & 17 deletions push.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,25 @@ def push(status, push_message):
return 0
if cfg.getboolean('setting', 'enable'):
log.info("正在执行推送......")
func_name = cfg.get('setting', 'push_server').lower()
func = globals().get(func_name)
# print(func)
if not func:
log.warning("推送服务名称错误:请检查config/push.ini -> [setting] -> push_server")
return 0
log.debug(f"推送所用的服务为:{func_name}")
try:
if not config.update_config_need:
func(title(status), push_message)
func_names = cfg.get('setting', 'push_server').lower()
for func_name in func_names.split(","):
func = globals().get(func_name)
# print(func)
if not func:
log.warning("推送服务名称错误:请检查config/push.ini -> [setting] -> push_server")
return 0
log.debug(f"推送所用的服务为:{func_name}")
try:
if not config.update_config_need:
func(title(status), push_message)
else:
func('「米游社脚本」config可能需要手动更新',
f'如果您多次收到此消息开头的推送,证明您运行的环境无法自动更新config,请手动更新一下,谢谢\r\n{title(status)}\r\n{push_message}')
except Exception as r:
log.warning(f"推送执行错误:{str(r)}")
return 0
else:
func('「米游社脚本」config可能需要手动更新',
f'如果您多次收到此消息开头的推送,证明您运行的环境无法自动更新config,请手动更新一下,谢谢\r\n{title(status)}\r\n{push_message}')
except Exception as r:
log.warning(f"推送执行错误:{str(r)}")
return 0
else:
log.info("推送完毕......")
log.info(f"{func_name} - 推送完毕......")
return 1


Expand Down

0 comments on commit 42dfa56

Please sign in to comment.