commit
c984a9f9e5
@ -46,6 +46,12 @@ api_url=http://xxx.xxx.cn
|
||||
token=AMxxxx
|
||||
priority=7
|
||||
|
||||
[ifttt]
|
||||
# If (Receive a web request) Then (Send a rich notification from the IFTTT app)
|
||||
# 使用value1(标题),value2(内容)
|
||||
event=mihoyo_push
|
||||
key=xxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# 邮件推送
|
||||
[smtp]
|
||||
# 一般情况下,465端口会使用ssl加密默认465端口,不加密走25端口。
|
||||
|
33
push.py
33
push.py
@ -77,14 +77,15 @@ def cqhttp(send_title, push_message):
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# smtp mail(电子邮件)
|
||||
# 感谢 @islandwind 提供的随机壁纸api 个人主页:https://space.bilibili.com/7600422
|
||||
def smtp(send_title, push_message):
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
|
||||
IMAGE_API = "http://api.iw233.cn/api.php?sort=random&type=json"
|
||||
|
||||
|
||||
try:
|
||||
image_url = http.get(IMAGE_API).json()["pic"][0]
|
||||
except:
|
||||
@ -116,7 +117,7 @@ def wecom(send_title, push_message):
|
||||
except:
|
||||
# 没有配置时赋默认值
|
||||
touser = '@all'
|
||||
|
||||
|
||||
push_token = http.post(
|
||||
url=f'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpid}&corpsecret={secret}',
|
||||
data=""
|
||||
@ -160,7 +161,7 @@ def dingrobot(send_title, push_message):
|
||||
).digest()
|
||||
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
|
||||
api_url = f"{api_url}×tamp={timestamp}&sign={sign}"
|
||||
|
||||
|
||||
rep = http.post(
|
||||
url=api_url,
|
||||
headers={"Content-Type": "application/json; charset=utf-8"},
|
||||
@ -170,6 +171,7 @@ def dingrobot(send_title, push_message):
|
||||
).json()
|
||||
log.info(f"推送结果:{rep.get('errmsg')}")
|
||||
|
||||
|
||||
# 飞书机器人
|
||||
def feishubot(send_title, push_message):
|
||||
api_url = cfg.get('feishubot', 'webhook') # https://open.feishu.cn/open-apis/bot/v2/hook/XXX
|
||||
@ -182,6 +184,7 @@ def feishubot(send_title, push_message):
|
||||
).json()
|
||||
log.info(f"推送结果:{rep.get('msg')}")
|
||||
|
||||
|
||||
# Bark
|
||||
def bark(send_title, push_message):
|
||||
rep = http.get(
|
||||
@ -203,6 +206,26 @@ def gotify(send_title, push_message):
|
||||
).json()
|
||||
log.info(f"推送结果:{rep.get('errmsg')}")
|
||||
|
||||
# ifttt
|
||||
def ifttt(send_title, push_message):
|
||||
ifttt_event = cfg.get('ifttt', 'event')
|
||||
ifttt_key = cfg.get('ifttt', 'key')
|
||||
rep = http.post(
|
||||
url=f'https://maker.ifttt.com/trigger/{ifttt_event}/with/key/{ifttt_key}',
|
||||
headers={"Content-Type": "application/json; charset=utf-8"},
|
||||
json={
|
||||
"value1": send_title,
|
||||
"value2": push_message
|
||||
}
|
||||
)
|
||||
if 'errors' in rep.text:
|
||||
log.warning(f"推送执行错误:{rep.json()['errors']}")
|
||||
return 0
|
||||
else:
|
||||
log.info("推送完毕......")
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
def push(status, push_message):
|
||||
if not load_config():
|
||||
@ -223,7 +246,7 @@ def push(status, push_message):
|
||||
func(title(status), push_message)
|
||||
else:
|
||||
func('「米游社脚本」config可能需要手动更新',
|
||||
f'如果您多次收到此消息开头的推送,证明您运行的环境无法自动更新config,请手动更新一下,谢谢\r\n{title(status)}\r\n{push_message}')
|
||||
f'如果您多次收到此消息开头的推送,证明您运行的环境无法自动更新config,请手动更新一下,谢谢\r\n{title(status)}\r\n{push_message}')
|
||||
except Exception as r:
|
||||
log.warning(f"推送执行错误:{str(r)}")
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user