From 47280f11248be0a50408bd63a9a935e182d14eee Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:03:53 +0800 Subject: [PATCH] =?UTF-8?q?tg=20=E6=8E=A8=E9=80=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/push.ini.example | 9 +++++++-- push.py | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config/push.ini.example b/config/push.ini.example index f9df942..f5cc758 100644 --- a/config/push.ini.example +++ b/config/push.ini.example @@ -1,6 +1,6 @@ [setting] enable=false -#共有 cqhttp ftqq(sever酱) pushplus +#共有 cqhttp ftqq(sever酱) pushplus telegram push_server=cqhttp #server酱和pushplus的推送token push_token=123456 @@ -9,4 +9,9 @@ push_token=123456 #cqhttp的服务端地址 cqhttp_url=http://127.0.0.1:5000/send_private_msg #推送给谁 -cqhttp_qq=10001 \ No newline at end of file +cqhttp_qq=10001 + +[telegram] +api_url=api.telegram.org +bot_token=123465:abcdefg +chat_id=123456 \ No newline at end of file diff --git a/push.py b/push.py index bf238ce..70ff873 100644 --- a/push.py +++ b/push.py @@ -22,6 +22,16 @@ def title(status): return "「米游社脚本」执行失败!" +def telegram(status, push_message): + http.post( + url="https://{}/bot{}/sendMessage".format(cfg.get('telegram', 'api_url'), cfg.get('telegram', 'bot_token')), + data={ + "chat_id": cfg.get('telegram', 'chat_id'), + "text": title(status) + "\r\n" + push_message + } + ) + + def ftqq(status, push_message): http.post( url="https://sctapi.ftqq.com/{}.send".format(cfg.get('setting', 'push_token')), @@ -66,5 +76,7 @@ def push(status, push_message): ftqq(status, push_message) elif push_server == "pushplus": pushplus(status, push_message) + elif push_server == "telegram": + telegram(status, push_message) log.info("推送完毕......") return 0