Squashed commit of the following:
commit 8724c545a8af8f34565aa71620e66cbd71547f37 Author: DLmaster <DLmaster_361@163.com> Date: Fri Apr 11 18:08:28 2025 +0800 feat(core): 预接入mirrorc commit d57ebaa281ff7c418aa8f11fe8e8ba260d8dbeca Author: DLmaster <DLmaster_361@163.com> Date: Thu Apr 10 12:37:26 2025 +0800 chore(core): 基础配置相关内容重构 - 添加理智药设置选项 #34 - 输入对话框添加回车键确认能力 #35 - 用户列表UI改版升级 - 配置类取消单例限制 - 配置读取方式与界面渲染方法优化 commit 710542287d04719c8443b91acb227de1dccc20d0 Author: DLmaster <DLmaster_361@163.com> Date: Fri Mar 28 23:32:17 2025 +0800 chore(core): search相关结构重整 commit 8009c69236655e29119ce62ff53a0360abaed2af Merge:648f42b9f88f92Author: DLmaster <DLmaster_361@163.com> Date: Mon Mar 24 15:31:40 2025 +0800 Merge branch 'dev' into user_list_dev
This commit is contained in:
@@ -53,7 +53,7 @@ class Notification(QWidget):
|
||||
def push_plyer(self, title, message, ticker, t):
|
||||
"""推送系统通知"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfPushPlyer):
|
||||
if Config.get(Config.notify_IfPushPlyer):
|
||||
|
||||
notification.notify(
|
||||
title=title,
|
||||
@@ -70,27 +70,21 @@ class Notification(QWidget):
|
||||
def send_mail(self, mode, title, content) -> None:
|
||||
"""推送邮件通知"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfSendMail):
|
||||
if Config.get(Config.notify_IfSendMail):
|
||||
|
||||
if (
|
||||
Config.global_config.get(Config.global_config.notify_SMTPServerAddress)
|
||||
== ""
|
||||
or Config.global_config.get(
|
||||
Config.global_config.notify_AuthorizationCode
|
||||
)
|
||||
== ""
|
||||
Config.get(Config.notify_SMTPServerAddress) == ""
|
||||
or Config.get(Config.notify_AuthorizationCode) == ""
|
||||
or not bool(
|
||||
re.match(
|
||||
r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$",
|
||||
Config.global_config.get(
|
||||
Config.global_config.notify_FromAddress
|
||||
),
|
||||
Config.get(Config.notify_FromAddress),
|
||||
)
|
||||
)
|
||||
or not bool(
|
||||
re.match(
|
||||
r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$",
|
||||
Config.global_config.get(Config.global_config.notify_ToAddress),
|
||||
Config.get(Config.notify_ToAddress),
|
||||
)
|
||||
)
|
||||
):
|
||||
@@ -114,15 +108,13 @@ class Notification(QWidget):
|
||||
message["From"] = formataddr(
|
||||
(
|
||||
Header("AUTO_MAA通知服务", "utf-8").encode(),
|
||||
Config.global_config.get(
|
||||
Config.global_config.notify_FromAddress
|
||||
),
|
||||
Config.get(Config.notify_FromAddress),
|
||||
)
|
||||
) # 发件人显示的名字
|
||||
message["To"] = formataddr(
|
||||
(
|
||||
Header("AUTO_MAA用户", "utf-8").encode(),
|
||||
Config.global_config.get(Config.global_config.notify_ToAddress),
|
||||
Config.get(Config.notify_ToAddress),
|
||||
)
|
||||
) # 收件人显示的名字
|
||||
message["Subject"] = Header(title, "utf-8")
|
||||
@@ -131,22 +123,16 @@ class Notification(QWidget):
|
||||
message.attach(MIMEText(content, "html", "utf-8"))
|
||||
|
||||
smtpObj = smtplib.SMTP_SSL(
|
||||
Config.global_config.get(
|
||||
Config.global_config.notify_SMTPServerAddress
|
||||
),
|
||||
Config.get(Config.notify_SMTPServerAddress),
|
||||
465,
|
||||
)
|
||||
smtpObj.login(
|
||||
Config.global_config.get(Config.global_config.notify_FromAddress),
|
||||
Crypto.win_decryptor(
|
||||
Config.global_config.get(
|
||||
Config.global_config.notify_AuthorizationCode
|
||||
)
|
||||
),
|
||||
Config.get(Config.notify_FromAddress),
|
||||
Crypto.win_decryptor(Config.get(Config.notify_AuthorizationCode)),
|
||||
)
|
||||
smtpObj.sendmail(
|
||||
Config.global_config.get(Config.global_config.notify_FromAddress),
|
||||
Config.global_config.get(Config.global_config.notify_ToAddress),
|
||||
Config.get(Config.notify_FromAddress),
|
||||
Config.get(Config.notify_ToAddress),
|
||||
message.as_string(),
|
||||
)
|
||||
smtpObj.quit()
|
||||
@@ -158,12 +144,9 @@ class Notification(QWidget):
|
||||
def ServerChanPush(self, title, content):
|
||||
"""使用Server酱推送通知"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfServerChan):
|
||||
if Config.get(Config.notify_IfServerChan):
|
||||
|
||||
if (
|
||||
Config.global_config.get(Config.global_config.notify_ServerChanKey)
|
||||
== ""
|
||||
):
|
||||
if Config.get(Config.notify_ServerChanKey) == "":
|
||||
logger.error("请正确设置Server酱的SendKey")
|
||||
self.push_info_bar.emit(
|
||||
"error",
|
||||
@@ -173,9 +156,7 @@ class Notification(QWidget):
|
||||
)
|
||||
return None
|
||||
else:
|
||||
send_key = Config.global_config.get(
|
||||
Config.global_config.notify_ServerChanKey
|
||||
)
|
||||
send_key = Config.get(Config.notify_ServerChanKey)
|
||||
|
||||
option = {}
|
||||
is_valid = lambda s: s == "" or (
|
||||
@@ -186,16 +167,11 @@ class Notification(QWidget):
|
||||
允许空的Tag和Channel即不启用,但不允许例如a||b,|a|b,a|b|,||||
|
||||
"""
|
||||
send_tag = "|".join(
|
||||
_.strip()
|
||||
for _ in Config.global_config.get(
|
||||
Config.global_config.notify_ServerChanTag
|
||||
).split("|")
|
||||
_.strip() for _ in Config.get(Config.notify_ServerChanTag).split("|")
|
||||
)
|
||||
send_channel = "|".join(
|
||||
_.strip()
|
||||
for _ in Config.global_config.get(
|
||||
Config.global_config.notify_ServerChanChannel
|
||||
).split("|")
|
||||
for _ in Config.get(Config.notify_ServerChanChannel).split("|")
|
||||
)
|
||||
|
||||
if is_valid(send_tag):
|
||||
@@ -239,14 +215,9 @@ class Notification(QWidget):
|
||||
|
||||
def CompanyWebHookBotPush(self, title, content):
|
||||
"""使用企业微信群机器人推送通知"""
|
||||
if Config.global_config.get(Config.global_config.notify_IfCompanyWebHookBot):
|
||||
if Config.get(Config.notify_IfCompanyWebHookBot):
|
||||
|
||||
if (
|
||||
Config.global_config.get(
|
||||
Config.global_config.notify_CompanyWebHookBotUrl
|
||||
)
|
||||
== ""
|
||||
):
|
||||
if Config.get(Config.notify_CompanyWebHookBotUrl) == "":
|
||||
logger.error("请正确设置企业微信群机器人的WebHook地址")
|
||||
self.push_info_bar.emit(
|
||||
"error",
|
||||
@@ -259,9 +230,7 @@ class Notification(QWidget):
|
||||
content = f"{title}\n{content}"
|
||||
data = {"msgtype": "text", "text": {"content": content}}
|
||||
response = requests.post(
|
||||
url=Config.global_config.get(
|
||||
Config.global_config.notify_CompanyWebHookBotUrl
|
||||
),
|
||||
url=Config.get(Config.notify_CompanyWebHookBotUrl),
|
||||
json=data,
|
||||
)
|
||||
if response.json()["errcode"] == 0:
|
||||
@@ -291,7 +260,7 @@ class Notification(QWidget):
|
||||
)
|
||||
|
||||
# 发送邮件通知
|
||||
if Config.global_config.get(Config.global_config.notify_IfSendMail):
|
||||
if Config.get(Config.notify_IfSendMail):
|
||||
self.send_mail(
|
||||
"文本",
|
||||
"AUTO_MAA测试通知",
|
||||
@@ -299,14 +268,14 @@ class Notification(QWidget):
|
||||
)
|
||||
|
||||
# 发送Server酱通知
|
||||
if Config.global_config.get(Config.global_config.notify_IfServerChan):
|
||||
if Config.get(Config.notify_IfServerChan):
|
||||
self.ServerChanPush(
|
||||
"AUTO_MAA测试通知",
|
||||
"这是 AUTO_MAA 外部通知测试信息。如果你看到了这段内容,说明 AUTO_MAA 的通知功能已经正确配置且可以正常工作!",
|
||||
)
|
||||
|
||||
# 发送企业微信机器人通知
|
||||
if Config.global_config.get(Config.global_config.notify_IfCompanyWebHookBot):
|
||||
if Config.get(Config.notify_IfCompanyWebHookBot):
|
||||
self.CompanyWebHookBotPush(
|
||||
"AUTO_MAA测试通知",
|
||||
"这是 AUTO_MAA 外部通知测试信息。如果你看到了这段内容,说明 AUTO_MAA 的通知功能已经正确配置且可以正常工作!",
|
||||
|
||||
Reference in New Issue
Block a user