feat: 添加通知测试接口

This commit is contained in:
DLmaster361
2025-09-10 20:33:05 +08:00
parent 6138fc47b1
commit d207c65df7
4 changed files with 61 additions and 44 deletions

View File

@@ -594,7 +594,7 @@ class MaaManager:
self.if_open_emulator = True
# 推送异常通知
Notify.push_plyer(
await Notify.push_plyer(
"用户自动代理出现异常!",
f"用户 {user['name']}{MOOD_BOOK[mode]}部分出现一次异常",
f"{user['name']}{MOOD_BOOK[mode]}出现异常",
@@ -914,7 +914,7 @@ class MaaManager:
logger.success(
f"用户 {self.user_list[self.index]['user_id']} 的自动代理任务已完成"
)
Notify.push_plyer(
await Notify.push_plyer(
"成功完成一个自动代理任务!",
f"已完成用户 {self.user_list[self.index]['name']} 的自动代理任务",
f"已完成 {self.user_list[self.index]['name']} 的自动代理任务",
@@ -1055,7 +1055,7 @@ class MaaManager:
result_text += f"\n未开始{self.mode}的用户: \n{"\n".join(result["waiting_user"])}\n"
# 推送代理结果通知
Notify.push_plyer(
await Notify.push_plyer(
title.replace("报告", "已完成!"),
f"已完成用户数: {len(over_user)}, 未完成用户数: {len(error_user) + len(wait_user)}",
f"已完成用户数: {len(over_user)}, 未完成用户数: {len(error_user) + len(wait_user)}",
@@ -1901,19 +1901,19 @@ class MaaManager:
# 发送全局通知
if Config.get("Notify", "IfSendMail"):
Notify.send_mail(
await Notify.send_mail(
"网页", title, message_html, Config.get("Notify", "ToAddress")
)
if Config.get("Notify", "IfServerChan"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
Config.get("Notify", "ServerChanKey"),
)
if Config.get("Notify", "IfCompanyWebHookBot"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
Config.get("Notify", "CompanyWebHookBotUrl"),
@@ -1955,19 +1955,19 @@ class MaaManager:
if Config.get("Notify", "IfSendStatistic"):
if Config.get("Notify", "IfSendMail"):
Notify.send_mail(
await Notify.send_mail(
"网页", title, message_html, Config.get("Notify", "ToAddress")
)
if Config.get("Notify", "IfServerChan"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
Config.get("Notify", "ServerChanKey"),
)
if Config.get("Notify", "IfCompanyWebHookBot"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
Config.get("Notify", "CompanyWebHookBotUrl"),
@@ -1981,7 +1981,7 @@ class MaaManager:
# 发送邮件通知
if self.cur_user_data.get("Notify", "IfSendMail"):
if self.cur_user_data.get("Notify", "ToAddress"):
Notify.send_mail(
await Notify.send_mail(
"网页",
title,
message_html,
@@ -1993,7 +1993,7 @@ class MaaManager:
# 发送ServerChan通知
if self.cur_user_data.get("Notify", "IfServerChan"):
if self.cur_user_data.get("Notify", "ServerChanKey"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "ServerChanKey"),
@@ -2006,7 +2006,7 @@ class MaaManager:
# 推送CompanyWebHookBot通知
if self.cur_user_data.get("Notify", "IfCompanyWebHookBot"):
if self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"),
@@ -2027,24 +2027,24 @@ class MaaManager:
if Config.get("Notify", "IfSendSixStar"):
if Config.get("Notify", "IfSendMail"):
Notify.send_mail(
await Notify.send_mail(
"网页", title, message_html, Config.get("Notify", "ToAddress")
)
if Config.get("Notify", "IfServerChan"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
"好羡慕~\n\nAUTO_MAA 敬上",
Config.get("Notify", "ServerChanKey"),
)
if Config.get("Notify", "IfCompanyWebHookBot"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
"好羡慕~\n\nAUTO_MAA 敬上",
Config.get("Notify", "CompanyWebHookBotUrl"),
)
Notify.CompanyWebHookBotPushImage(
await Notify.CompanyWebHookBotPushImage(
Path.cwd() / "res/images/notification/six_star.png",
Config.get("Notify", "CompanyWebHookBotUrl"),
)
@@ -2057,7 +2057,7 @@ class MaaManager:
# 发送邮件通知
if self.cur_user_data.get("Notify", "IfSendMail"):
if self.cur_user_data.get("Notify", "ToAddress"):
Notify.send_mail(
await Notify.send_mail(
"网页",
title,
message_html,
@@ -2070,7 +2070,7 @@ class MaaManager:
if self.cur_user_data.get("Notify", "IfServerChan"):
if self.cur_user_data.get("Notify", "ServerChanKey"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
"好羡慕~\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "ServerChanKey"),
@@ -2083,12 +2083,12 @@ class MaaManager:
# 推送CompanyWebHookBot通知
if self.cur_user_data.get("Notify", "IfCompanyWebHookBot"):
if self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
"好羡慕~\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"),
)
Notify.CompanyWebHookBotPushImage(
await Notify.CompanyWebHookBotPushImage(
Path.cwd() / "res/images/notification/six_star.png",
self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"),
)

View File

@@ -454,7 +454,7 @@ class GeneralManager:
await System.kill_process(self.game_path)
# 推送异常通知
Notify.push_plyer(
await Notify.push_plyer(
"用户自动代理出现异常!",
f"用户 {user['name']} 的自动代理出现一次异常",
f"{user['name']} 的自动代理出现异常",
@@ -576,7 +576,7 @@ class GeneralManager:
logger.success(
f"用户 {self.user_list[self.index]['user_id']} 的自动代理任务已完成"
)
Notify.push_plyer(
await Notify.push_plyer(
"成功完成一个自动代理任务!",
f"已完成用户 {self.user_list[self.index]['name']} 的自动代理任务",
f"已完成 {self.user_list[self.index]['name']} 的自动代理任务",
@@ -703,7 +703,7 @@ class GeneralManager:
result_text += f"\n未开始{self.mode}的用户: \n{"\n".join(result['waiting_user'])}\n"
# 推送代理结果通知
Notify.push_plyer(
await Notify.push_plyer(
title.replace("报告", "已完成!"),
f"已完成配置数: {len(over_user)}, 未完成配置数: {len(error_user) + len(wait_user)}",
f"已完成配置数: {len(over_user)}, 未完成配置数: {len(error_user) + len(wait_user)}",
@@ -979,19 +979,19 @@ class GeneralManager:
# 发送全局通知
if Config.get("Notify", "IfSendMail"):
Notify.send_mail(
await Notify.send_mail(
"网页", title, message_html, Config.get("Notify", "ToAddress")
)
if Config.get("Notify", "IfServerChan"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
Config.get("Notify", "ServerChanKey"),
)
if Config.get("Notify", "IfCompanyWebHookBot"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
Config.get("Notify", "CompanyWebHookBotUrl"),
@@ -1016,19 +1016,19 @@ class GeneralManager:
if Config.get("Notify", "IfSendStatistic"):
if Config.get("Notify", "IfSendMail"):
Notify.send_mail(
await Notify.send_mail(
"网页", title, message_html, Config.get("Notify", "ToAddress")
)
if Config.get("Notify", "IfServerChan"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
Config.get("Notify", "ServerChanKey"),
)
if Config.get("Notify", "IfCompanyWebHookBot"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
Config.get("Notify", "CompanyWebHookBotUrl"),
@@ -1042,7 +1042,7 @@ class GeneralManager:
# 发送邮件通知
if self.cur_user_data.get("Notify", "IfSendMail"):
if self.cur_user_data.get("Notify", "ToAddress"):
Notify.send_mail(
await Notify.send_mail(
"网页",
title,
message_html,
@@ -1054,7 +1054,7 @@ class GeneralManager:
# 发送ServerChan通知
if self.cur_user_data.get("Notify", "IfServerChan"):
if self.cur_user_data.get("Notify", "ServerChanKey"):
Notify.ServerChanPush(
await Notify.ServerChanPush(
title,
f"{serverchan_message}\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "ServerChanKey"),
@@ -1067,7 +1067,7 @@ class GeneralManager:
# 推送CompanyWebHookBot通知
if self.cur_user_data.get("Notify", "IfCompanyWebHookBot"):
if self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"):
Notify.WebHookPush(
await Notify.WebHookPush(
title,
f"{message_text}\n\nAUTO_MAA 敬上",
self.cur_user_data.get("Notify", "CompanyWebHookBotUrl"),