Revert "- 新增Server酱与企业微信群机器人推送代理成功渠道。"

This reverts commit df96183f42.
This commit is contained in:
heziziziscool
2025-02-03 18:54:09 +08:00
parent df96183f42
commit 94a9bdbb93
5 changed files with 13 additions and 190 deletions

View File

@@ -24,14 +24,13 @@ AUTO_MAA通知服务
v4.2
作者DLmaster_361
"""
import requests
from plyer import notification
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.utils import formataddr
from serverchan_sdk import sc_send
from loguru import logger
from app.core import Config
@@ -41,6 +40,7 @@ class Notification:
"""推送系统通知"""
if Config.global_config.get(Config.global_config.notify_IfPushPlyer):
notification.notify(
title=title,
message=message,
@@ -90,70 +90,11 @@ class Notification:
Config.global_config.get(Config.global_config.notify_MailAddress),
message.as_string(),
)
logger.info("邮件发送成功")
return True
except smtplib.SMTPException as e:
return f"发送邮件时出错:\n{e}"
finally:
smtpObj.quit()
def ServerChanPush(self, title, content):
"""使用Server酱推送通知"""
if Config.global_config.get(Config.global_config.notify_IfServerChan):
send_key = Config.global_config.get(Config.global_config.notify_ServerChanKey)
option = {}
is_valid = lambda s: s == "" or (s == '|'.join(s.split('|')) and (s.count('|') == 0 or all(s.split('|'))))
"""
is_valid => True, 如果启用的话需要正确设置Tag和Channel。
允许空的Tag和Channel即不启用但不允许例如a||b|a|ba|b|||||
"""
send_tag = Config.global_config.get(Config.global_config.notify_ServerChanTag)
send_channel = Config.global_config.get(Config.global_config.notify_ServerChanChannel)
if is_valid(send_tag):
option['tags'] = send_tag
else:
option['tags'] = ''
logger.warning('请正确设置Auto_MAA中ServerChan的Tag。')
if is_valid(send_channel):
option['channel'] = send_channel
else:
option['channel'] = ''
logger.warning('请正确设置Auto_MAA中ServerChan的Channel。')
response = sc_send(send_key, title, content, option)
if response["code"] == 0:
logger.info("Server酱推送通知成功")
return True
else:
logger.info("Server酱推送通知失败")
logger.error(response)
return f'使用Server酱推送通知时出错\n{response["data"]['error']}'
def CompanyWebHookBotPush(self, title, content):
"""使用企业微信群机器人推送通知"""
if Config.global_config.get(Config.global_config.notify_IfCompanyWebHookBot):
content = f'{title}\n{content}'
data = {
"msgtype": "text",
"text": {
"content": content
}
}
response = requests.post(
url=Config.global_config.get(Config.global_config.notify_CompanyWebHookBotUrl),
json=data
)
if response.json()["errcode"] == 0:
logger.info("企业微信群机器人推送通知成功")
return True
else:
logger.info("企业微信群机器人推送通知失败")
logger.error(response.json())
return f'使用企业微信群机器人推送通知时出错:\n{response.json()["errmsg"]}'
Notify = Notification()