From 8109d87c5fbade3ab52b256030a1e57d145a7e67 Mon Sep 17 00:00:00 2001 From: Echowxsy Date: Mon, 14 Jan 2019 20:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=92=89=E9=92=89=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py12306/helpers/notification.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/py12306/helpers/notification.py b/py12306/helpers/notification.py index 50345cd..5d1b234 100644 --- a/py12306/helpers/notification.py +++ b/py12306/helpers/notification.py @@ -20,6 +20,11 @@ class Notification(): self = cls() self.send_voice_code_of_yiyuan(phone, name=name, content=content) + @classmethod + def dingtalk_webhook(cls, content=''): + self = cls() + self.send_dingtalk_by_webbook(content=content) + @classmethod def send_email(cls, to, title='', content=''): self = cls() @@ -77,9 +82,17 @@ class Notification(): except Exception as e: CommonLog.add_quick_log(CommonLog.MESSAGE_SEND_EMAIL_FAIL.format(e)).flush() + def send_dingtalk_by_webbook(self,content): + from dingtalkchatbot.chatbot import DingtalkChatbot + webhook = Config().DINGTALK_WEBHOOK + dingtalk = DingtalkChatbot(webhook) + dingtalk.send_text(msg=content, is_at_all=True) + pass + if __name__ == '__main__': name = '张三4' content = '你的车票 广州 到 深圳 购买成功,请登录 12306 进行支付' # Notification.voice_code('13800138000', name, content) Notification.send_email('user@email.com', name, content) + Notification.dingtalk_webhook(content)