From 0a9680392c12af23dea45fe05b0767f88da47ca7 Mon Sep 17 00:00:00 2001 From: x1ah Date: Thu, 11 Nov 2021 23:57:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=A3=9E=E4=B9=A6?= =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.json | 1 + index.py | 2 ++ notify.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/config/config.json b/config/config.json index 080771d..3074c8e 100644 --- a/config/config.json +++ b/config/config.json @@ -7,6 +7,7 @@ "lotteryNum": "抽奖次数(选填,不填请删除此行)", "woEmail": "沃邮箱俱乐部登陆Url(选填,不填请删除此行)", "dingtalkWebhook": "钉钉通知 https://oapi.dingtalk.com/robot/send?access_token=xxxx(选填,不填请删除此行)", + "larkWebhook": "飞书自定义机器人通知 https://open.feishu.cn/open-apis/bot/v2/hook/xxx(选填,不填请删除此行)", "Bark": { "Barkkey": "(选填,不填请删除 Bark 对象)", "Barksave": "//是否需要保存推送信息到历史记录,1 为保存,其他值为不保存。(选填,不填请删除 Bark 对象)" diff --git a/index.py b/index.py index 0e752d6..4e071cc 100644 --- a/index.py +++ b/index.py @@ -48,6 +48,8 @@ def sendNotice(user): notify.sendIFTTT(user['IFTTT']) if('Bark' in user) : notify.sendBark(user['Bark']) + if "larkWebhook" in user: + notify.send_lark(user["larkWebhook"]) #腾讯云函数入口 def main_handler(event, context): diff --git a/notify.py b/notify.py index 60d3048..d6d89e3 100644 --- a/notify.py +++ b/notify.py @@ -236,3 +236,25 @@ def sendBark(Bark): resp = session.post(url, json = data, headers = headers) state=json.loads(resp.text) print(state) + + +def send_lark(webhook): + """飞书自定义机器人消息推送""" + content = readFile_text("./log.txt") + data = { + "msg_type": "post", + "content": { + "post": { + "zh_cn": { + "title": "UnicomTask每日报表", + "content": [ + [{ + "tag": "text", + "text": content + }] + ] + } + } + } + } + resp = requests.post(webhook, json=data) \ No newline at end of file