Update notify.py

pull/46/head
StarsL.cn 2022-11-26 19:59:45 +08:00 committed by GitHub
parent 9b4723872b
commit d714efafd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -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 = "<at id=all></at>" if isatall else ''
params = {"msg_type": "interactive",
"card": {"header": {"title": {"tag": "plain_text","content": title},"template": "red"},
"elements": [{"tag": "markdown","content": f"{md}\n<at id=all></at>",}]}}
"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)