refactor(config): 重构通知配置项并优化Webhook获取逻辑
This commit is contained in:
@@ -105,10 +105,7 @@ class GlobalConfig(ConfigBase):
|
||||
Notify_ToAddress = ConfigItem("Notify", "ToAddress", "")
|
||||
Notify_IfServerChan = ConfigItem("Notify", "IfServerChan", False, BoolValidator())
|
||||
Notify_ServerChanKey = ConfigItem("Notify", "ServerChanKey", "")
|
||||
Notify_IfCompanyWebHookBot = ConfigItem(
|
||||
"Notify", "IfCompanyWebHookBot", False, BoolValidator()
|
||||
)
|
||||
Notify_CompanyWebHookBotUrl = ConfigItem("Notify", "CompanyWebHookBotUrl", "")
|
||||
Notify_CustomWebhooks = ConfigItem("Notify", "CustomWebhooks", [])
|
||||
|
||||
Update_IfAutoUpdate = ConfigItem("Update", "IfAutoUpdate", False, BoolValidator())
|
||||
Update_Source = ConfigItem(
|
||||
@@ -348,12 +345,7 @@ class MaaUserConfig(ConfigBase):
|
||||
"Notify", "IfServerChan", False, BoolValidator()
|
||||
)
|
||||
self.Notify_ServerChanKey = ConfigItem("Notify", "ServerChanKey", "")
|
||||
self.Notify_IfCompanyWebHookBot = ConfigItem(
|
||||
"Notify", "IfCompanyWebHookBot", False, BoolValidator()
|
||||
)
|
||||
self.Notify_CompanyWebHookBotUrl = ConfigItem(
|
||||
"Notify", "CompanyWebHookBotUrl", ""
|
||||
)
|
||||
self.Notify_CustomWebhooks = ConfigItem("Notify", "CustomWebhooks", [])
|
||||
|
||||
def get_plan_info(self) -> Dict[str, Union[str, int]]:
|
||||
"""获取当前的计划下信息"""
|
||||
@@ -541,12 +533,7 @@ class GeneralUserConfig(ConfigBase):
|
||||
"Notify", "IfServerChan", False, BoolValidator()
|
||||
)
|
||||
self.Notify_ServerChanKey = ConfigItem("Notify", "ServerChanKey", "")
|
||||
self.Notify_IfCompanyWebHookBot = ConfigItem(
|
||||
"Notify", "IfCompanyWebHookBot", False, BoolValidator()
|
||||
)
|
||||
self.Notify_CompanyWebHookBotUrl = ConfigItem(
|
||||
"Notify", "CompanyWebHookBotUrl", ""
|
||||
)
|
||||
self.Notify_CustomWebhooks = ConfigItem("Notify", "CustomWebhooks", [])
|
||||
|
||||
|
||||
class GeneralConfig(ConfigBase):
|
||||
|
||||
@@ -357,7 +357,10 @@ class Notification:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
|
||||
@@ -1907,7 +1907,10 @@ class MaaManager:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
@@ -1970,7 +1973,10 @@ class MaaManager:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
@@ -2055,7 +2061,10 @@ class MaaManager:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知(六星喜报)
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
|
||||
@@ -983,7 +983,10 @@ class GeneralManager:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
@@ -1027,7 +1030,10 @@ class GeneralManager:
|
||||
)
|
||||
|
||||
# 发送自定义Webhook通知
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks", [])
|
||||
try:
|
||||
custom_webhooks = Config.get("Notify", "CustomWebhooks")
|
||||
except AttributeError:
|
||||
custom_webhooks = []
|
||||
if custom_webhooks:
|
||||
for webhook in custom_webhooks:
|
||||
if webhook.get("enabled", True):
|
||||
|
||||
Reference in New Issue
Block a user