From d199c260a6a98641428680bf0dc0624fae549356 Mon Sep 17 00:00:00 2001 From: wuyoukm <28343933+wuyoukm@users.noreply.github.com> Date: Fri, 27 Aug 2021 17:30:36 +0800 Subject: [PATCH] Update github_cve_monitor.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配置文件标准化,修复BUG --- github_cve_monitor.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/github_cve_monitor.py b/github_cve_monitor.py index 1d9171d..1377282 100644 --- a/github_cve_monitor.py +++ b/github_cve_monitor.py @@ -27,21 +27,21 @@ def load_config(): with open('config.yaml', 'r') as f: config = yaml.load(f,Loader=yaml.FullLoader) github_token = config['all_config']['github_token'] - if int(config['all_config']['dingding'][0].split(":")[1]) == 1: - dingding_webhook = "https:"+config['all_config']['dingding'][1].split(":")[2] - dingding_secretKey = config['all_config']['dingding'][2].split(":")[1] - app_name = config['all_config']['dingding'][3].split(":")[1] + if int(config['all_config']['dingding'][0]['enable']) == 1: + dingding_webhook = config['all_config']['dingding'][1]['webhook'] + dingding_secretKey = config['all_config']['dingding'][2]['secretKey'] + app_name = config['all_config']['dingding'][3]['app_name'] return app_name,github_token,dingding_webhook,dingding_secretKey - elif int(config['all_config']['server'][0].split(":")[1]) == 1: - server_sckey = config['all_config']['server'][1].split(":")[1] - app_name = config['all_config']['server'][2].split(":")[1] + elif int(config['all_config']['server'][0]['enable']) == 1: + server_sckey = config['all_config']['server'][1]['sckey'] + app_name = config['all_config']['server'][2]['app_name'] return app_name,github_token,server_sckey - elif int(config['all_config']['tgbot'][0].split(":")[1]) ==1 : - tgbot_token = config['all_config']['tgbot'][1].split(":")[1] - tgbot_group_id = config['all_config']['tgbot'][2].split(":")[1] - app_name = config['all_config']['tgbot'][3].split(":")[1] + elif int(config['all_config']['tgbot'][0]['enable']) ==1 : + tgbot_token = config['all_config']['tgbot'][1]['token'] + tgbot_group_id = config['all_config']['tgbot'][2]['group_id'] + app_name = config['all_config']['tgbot'][3]['app_name'] return app_name,github_token,tgbot_token,tgbot_group_id - elif int(config['all_config']['tgbot'][0].split(":")[1]) == 0 and int(config['all_config']['server'][0].split(":")[1]) == 0 and int(config['all_config']['dingding'][0].split(":")[1]) == 0: + elif int(config['all_config']['tgbot'][0]['enable']) == 0 and int(config['all_config']['server'][0]['enable']) == 0 and int(config['all_config']['dingding'][0]['enable']) == 0: print("[-] 配置文件有误,三个社交软件的enable不能为0") logging.error("[-] 配置文件有误,三个社交软件的enable不能为0") @@ -423,4 +423,4 @@ if __name__ == '__main__': send_dingding(data3[i]['api_url'],data3[i]['pushed_at'],data3[i]['tag_name']) except Exception as e: print("main 函数 遇到错误-->{}".format(e)) - logging.error("main 函数 遇到错误-->{}".format(e)) \ No newline at end of file + logging.error("main 函数 遇到错误-->{}".format(e))