mirror of
https://github.com/TDSCDMAA/AutoMihoyoBBS.git
synced 2026-06-02 18:43:42 +08:00
tg 推送测试
This commit is contained in:
parent
9dcb3f0f4e
commit
47280f1124
@ -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
|
||||
cqhttp_qq=10001
|
||||
|
||||
[telegram]
|
||||
api_url=api.telegram.org
|
||||
bot_token=123465:abcdefg
|
||||
chat_id=123456
|
||||
12
push.py
12
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user