mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-15 01:47:20 +08:00
添加了类型判断,Onepush中某些中间件并不会返回Response而是返回NoneType(比如Discord)
Signed-off-by: Little_C <zxc7895531@outlook.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import yaml
|
|
||||||
import onepush.core
|
import onepush.core
|
||||||
|
import yaml
|
||||||
from onepush import get_notifier
|
from onepush import get_notifier
|
||||||
from onepush.core import Provider
|
from onepush.core import Provider
|
||||||
from onepush.exceptions import OnePushException
|
from onepush.exceptions import OnePushException
|
||||||
from onepush.providers.custom import Custom
|
from onepush.providers.custom import Custom
|
||||||
|
from requests import Response
|
||||||
|
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
|
|
||||||
@@ -49,10 +50,8 @@ def handle_notify(_config: str, **kwargs) -> bool:
|
|||||||
if access_token:
|
if access_token:
|
||||||
config["token"] = access_token
|
config["token"] = access_token
|
||||||
|
|
||||||
if provider_name.lower() == "smtp":
|
resp = notifier.notify(**config)
|
||||||
notifier.notify(**config)
|
if isinstance(resp, Response):
|
||||||
else:
|
|
||||||
resp = notifier.notify(**config)
|
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
logger.warning("Push notify failed!")
|
logger.warning("Push notify failed!")
|
||||||
logger.warning(f"HTTP Code:{resp.status_code}")
|
logger.warning(f"HTTP Code:{resp.status_code}")
|
||||||
@@ -62,7 +61,8 @@ def handle_notify(_config: str, **kwargs) -> bool:
|
|||||||
return_data: dict = resp.json()
|
return_data: dict = resp.json()
|
||||||
if return_data["status"] == "failed":
|
if return_data["status"] == "failed":
|
||||||
logger.warning("Push notify failed!")
|
logger.warning("Push notify failed!")
|
||||||
logger.warning(f"Return message:{return_data['wording']}")
|
logger.warning(
|
||||||
|
f"Return message:{return_data['wording']}")
|
||||||
return False
|
return False
|
||||||
except OnePushException:
|
except OnePushException:
|
||||||
logger.exception("Push notify failed")
|
logger.exception("Push notify failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user