From 26f24d611fe8d8c7aea5a8669b3f2a43ef4e947b Mon Sep 17 00:00:00 2001 From: clover1420 <748883120@qq.com> Date: Thu, 28 Apr 2022 00:41:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0qmsg=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 2 +- index.py | 1 - push/__init__.py | 8 ++++++++ push/qmsg.py | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 push/qmsg.py diff --git a/config.py b/config.py index 94f912a..7623315 100644 --- a/config.py +++ b/config.py @@ -24,5 +24,5 @@ # }, ], "together": True, # 是否合并发送结果, 不写或 True 时合并发送 - "push": "workWechat", # 推送类型, together 为 True 或者不写时必须有, 否则不推送 + "push": "qmsg", # 推送类型, together 为 True 或者不写时必须有, 否则不推送 } diff --git a/index.py b/index.py index 77fe262..df2d29d 100644 --- a/index.py +++ b/index.py @@ -2,7 +2,6 @@ from config import config from push import push - def main(*arg): together = config.get("together") type = config.get("push") diff --git a/push/__init__.py b/push/__init__.py index 5ec92b0..64f37e9 100644 --- a/push/__init__.py +++ b/push/__init__.py @@ -1,5 +1,6 @@ from .workWeChat import workWechatRobot, workWechatApp from .server import server +from .qmsg import qmsg from .pushplus import pushplus import os @@ -62,6 +63,13 @@ def push(type: str, title: str, content): ) except KeyError as key: print(f"未配置企业微信的 {key}") + elif type == "qmsg": + try: + key = os.environ["qmsg"] + # 这里推送文本消息 + res = qmsg(key).push_msg(dict2md.dict2md(content)) + except KeyError: + print("未配置 qmsg 酱 的 key") else: print("未找到相关推送服务") except Exception as ex: diff --git a/push/qmsg.py b/push/qmsg.py new file mode 100644 index 0000000..b6b446d --- /dev/null +++ b/push/qmsg.py @@ -0,0 +1,23 @@ +import requests + + +class qmsg: + """ + qmsg(https://qmsg.zendee.cn/api) + """ + + def __init__(self, key) -> None: + self.key = key + self.url = f"https://qmsg.zendee.cn:443/send/{self.key}" + + def push_msg(self, msg) -> None: + """ + Parameters: + msg: 消息内容 + """ + params = {"msg": msg} + res = requests.get(self.url, params=params).json() + if res["code"] == 0: + print("消息推送成功") + else: + print(f"推送错误, {res['info']}") From 67274c0b81fa03651bffee24172f6d39b2410bfb Mon Sep 17 00:00:00 2001 From: clover1420 <748883120@qq.com> Date: Thu, 28 Apr 2022 00:47:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0qmsg=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- push/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/push/__init__.py b/push/__init__.py index 64f37e9..3650f86 100644 --- a/push/__init__.py +++ b/push/__init__.py @@ -63,6 +63,7 @@ def push(type: str, title: str, content): ) except KeyError as key: print(f"未配置企业微信的 {key}") + #qmsg推送 elif type == "qmsg": try: key = os.environ["qmsg"]