From acd044b1fb77e1ba7d464718b22b83bfccaeb024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=80=9D?= Date: Tue, 18 Jul 2023 17:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0PushMe=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sample/notify.py b/sample/notify.py index b550e9a6..8e666ce7 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -98,6 +98,8 @@ push_config = { 'SMTP_EMAIL': '', # SMTP 收发件邮箱,通知将会由自己发给自己 'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定 'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写 + + 'PUSHME_KEY': '', # PushMe 酱的 PUSHME_KEY } notify_function = [] # fmt: on @@ -637,6 +639,27 @@ def smtp(title: str, content: str) -> None: except Exception as e: print(f"SMTP 邮件 推送失败!{e}") +def pushme(title: str, content: str) -> None: + """ + 使用 PushMe 推送消息。 + """ + if not push_config.get("PUSHME_KEY"): + print("PushMe 服务的 PUSHME_KEY 未设置!!\n取消推送") + return + print("PushMe 服务启动") + + url = f'https://push.i-i.me/?push_key={push_config.get("PUSHME_KEY")}' + data = { + "title": title, + "content": content, + } + response = requests.post(url, data=data) + + if response == 'success': + print("PushMe 推送成功!") + else: + print("PushMe 推送失败!{response}") + def one() -> str: """