mirror of
https://github.com/TDSCDMAA/AutoMihoyoBBS.git
synced 2026-06-12 22:58:31 +08:00
push
This commit is contained in:
parent
6a235de34c
commit
cdd593236a
25
push.py
25
push.py
@ -1,14 +1,13 @@
|
|||||||
import base64
|
|
||||||
import hashlib
|
|
||||||
import hmac
|
|
||||||
import os
|
import os
|
||||||
|
import hmac
|
||||||
import time
|
import time
|
||||||
import urllib
|
import base64
|
||||||
from configparser import ConfigParser
|
|
||||||
|
|
||||||
import config
|
import config
|
||||||
from loghelper import log
|
import urllib
|
||||||
|
import hashlib
|
||||||
from request import http
|
from request import http
|
||||||
|
from loghelper import log
|
||||||
|
from configparser import ConfigParser, NoOptionError
|
||||||
|
|
||||||
cfg = ConfigParser()
|
cfg = ConfigParser()
|
||||||
|
|
||||||
@ -77,6 +76,7 @@ def cqhttp(send_title, push_message):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# smtp mail(电子邮件)
|
# smtp mail(电子邮件)
|
||||||
# 感谢 @islandwind 提供的随机壁纸api 个人主页:https://space.bilibili.com/7600422
|
# 感谢 @islandwind 提供的随机壁纸api 个人主页:https://space.bilibili.com/7600422
|
||||||
def smtp(send_title, push_message):
|
def smtp(send_title, push_message):
|
||||||
@ -113,7 +113,7 @@ def wecom(send_title, push_message):
|
|||||||
corpid = cfg.get('wecom', 'wechat_id')
|
corpid = cfg.get('wecom', 'wechat_id')
|
||||||
try:
|
try:
|
||||||
touser = cfg.get('wecom', 'touser')
|
touser = cfg.get('wecom', 'touser')
|
||||||
except:
|
except NoOptionError:
|
||||||
# 没有配置时赋默认值
|
# 没有配置时赋默认值
|
||||||
touser = '@all'
|
touser = '@all'
|
||||||
|
|
||||||
@ -170,6 +170,7 @@ def dingrobot(send_title, push_message):
|
|||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('errmsg')}")
|
log.info(f"推送结果:{rep.get('errmsg')}")
|
||||||
|
|
||||||
|
|
||||||
# 飞书机器人
|
# 飞书机器人
|
||||||
def feishubot(send_title, push_message):
|
def feishubot(send_title, push_message):
|
||||||
api_url = cfg.get('feishubot', 'webhook') # https://open.feishu.cn/open-apis/bot/v2/hook/XXX
|
api_url = cfg.get('feishubot', 'webhook') # https://open.feishu.cn/open-apis/bot/v2/hook/XXX
|
||||||
@ -182,10 +183,12 @@ def feishubot(send_title, push_message):
|
|||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('msg')}")
|
log.info(f"推送结果:{rep.get('msg')}")
|
||||||
|
|
||||||
|
|
||||||
# Bark
|
# Bark
|
||||||
def bark(send_title, push_message):
|
def bark(send_title, push_message):
|
||||||
rep = http.get(
|
rep = http.get(
|
||||||
url=f'{cfg.get("bark", "api_url")}/{cfg.get("bark", "token")}/{send_title}/{push_message}?icon=https://cdn.jsdelivr.net/gh/tanmx/pic@main/mihoyo/{cfg.get("bark", "icon")}.png'
|
url=f'{cfg.get("bark", "api_url")}/{cfg.get("bark", "token")}/{send_title}/{push_message}?icon=https://cdn'
|
||||||
|
f'.jsdelivr.net/gh/tanmx/pic@main/mihoyo/{cfg.get("bark", "icon")}.png'
|
||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('message')}")
|
log.info(f"推送结果:{rep.get('message')}")
|
||||||
|
|
||||||
@ -217,13 +220,11 @@ def push(status, push_message):
|
|||||||
return 0
|
return 0
|
||||||
log.debug(f"推送所用的服务为:{func_name}")
|
log.debug(f"推送所用的服务为:{func_name}")
|
||||||
try:
|
try:
|
||||||
# eval(push_server[:10] + "(status, push_message)")
|
|
||||||
# 与面代码等效 20220508
|
|
||||||
if not config.update_config_need:
|
if not config.update_config_need:
|
||||||
func(title(status), push_message)
|
func(title(status), push_message)
|
||||||
else:
|
else:
|
||||||
func('「米游社脚本」config可能需要手动更新',
|
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:
|
except Exception as r:
|
||||||
log.warning(f"推送执行错误:{str(r)}")
|
log.warning(f"推送执行错误:{str(r)}")
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user