From d714efafd01caf65872402ccd5063eb3f5222f28 Mon Sep 17 00:00:00 2001 From: "StarsL.cn" Date: Sat, 26 Nov 2022 19:59:45 +0800 Subject: [PATCH] Update notify.py --- flask-consul/units/cloud/notify.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/flask-consul/units/cloud/notify.py b/flask-consul/units/cloud/notify.py index 9da0ca5..8e81e30 100644 --- a/flask-consul/units/cloud/notify.py +++ b/flask-consul/units/cloud/notify.py @@ -6,18 +6,19 @@ def wecom(webhook,content): response = requests.post(webhook, headers=headers, data=data) print('【wecom】',response.json(),flush=True) -def dingding(webhook,content): +def dingding(webhook,content,isatall=True): headers = {'Content-Type': 'application/json'} - params = {"msgtype":"markdown","markdown":{"title":"资源告警","text":content},"at":{"isAtAll":True}} + params = {"msgtype":"markdown","markdown":{"title":"资源告警","text":content},"at":{"isAtAll":isatall}} data = bytes(json.dumps(params), 'utf-8') response = requests.post(webhook, headers=headers, data=data) print('【dingding】',response.json(),flush=True) -def feishu(webhook,title,md): +def feishu(webhook,title,md,isatall=True): headers = {'Content-Type': 'application/json'} + atall = "" if isatall else '' params = {"msg_type": "interactive", "card": {"header": {"title": {"tag": "plain_text","content": title},"template": "red"}, - "elements": [{"tag": "markdown","content": f"{md}\n",}]}} + "elements": [{"tag": "markdown","content": f"{md}\n{atall}",}]}} data = json.dumps(params) response = requests.post(webhook, headers=headers, data=data) print('【feishu】',response.json(),flush=True)