This commit is contained in:
jxxghp
2024-07-06 08:30:09 +08:00
parent 059e4f08a3
commit 1a0c4acf1c
4 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ class _MessageBase:
return None return None
return self._configs.get(name) return self._configs.get(name)
def checkMessage(self, message: Notification, source: str) -> bool: def checkMessage(self, message: Notification, source: str = None) -> bool:
""" """
检查消息渠道及消息类型,如不符合则不处理 检查消息渠道及消息类型,如不符合则不处理
""" """
-2
View File
@@ -2,14 +2,12 @@ from pathlib import Path
from typing import Optional from typing import Optional
from xml.dom import minidom from xml.dom import minidom
from app.core.config import settings
from app.core.context import MediaInfo from app.core.context import MediaInfo
from app.schemas.types import MediaType from app.schemas.types import MediaType
from app.utils.dom import DomUtils from app.utils.dom import DomUtils
class DoubanScraper: class DoubanScraper:
_transfer_type = settings.TRANSFER_TYPE
_force_nfo = False _force_nfo = False
_force_img = False _force_img = False
-1
View File
@@ -11,7 +11,6 @@ from app.utils.dom import DomUtils
class TmdbScraper: class TmdbScraper:
tmdb = None tmdb = None
_transfer_type = settings.TRANSFER_TYPE
_force_nfo = False _force_nfo = False
_force_img = False _force_img = False
+7 -5
View File
@@ -5,11 +5,11 @@ from pywebpush import webpush, WebPushException
from app.core.config import global_vars, settings from app.core.config import global_vars, settings
from app.log import logger from app.log import logger
from app.modules import _ModuleBase from app.modules import _ModuleBase, _MessageBase
from app.schemas import MessageChannel, Notification from app.schemas import Notification
class WebPushModule(_ModuleBase): class WebPushModule(_ModuleBase, _MessageBase):
def init_module(self) -> None: def init_module(self) -> None:
pass pass
@@ -27,9 +27,8 @@ class WebPushModule(_ModuleBase):
return True, "" return True, ""
def init_setting(self) -> Tuple[str, Union[str, bool]]: def init_setting(self) -> Tuple[str, Union[str, bool]]:
return "MESSAGER", "webpush" pass
@checkMessage(MessageChannel.WebPush)
def post_message(self, message: Notification) -> None: def post_message(self, message: Notification) -> None:
""" """
发送消息 发送消息
@@ -39,6 +38,9 @@ class WebPushModule(_ModuleBase):
if not message.title and not message.text: if not message.title and not message.text:
logger.warn("标题和内容不能同时为空") logger.warn("标题和内容不能同时为空")
return return
if not self.checkMessage(message):
logger.warn("WebPush 通道未启用")
return
try: try:
if message.title: if message.title:
caption = message.title caption = message.title