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

View File

@@ -74,7 +74,7 @@ class _MessageBase:
return None
return self._configs.get(name)
def checkMessage(self, message: Notification, source: str) -> bool:
def checkMessage(self, message: Notification, source: str = None) -> bool:
"""
检查消息渠道及消息类型,如不符合则不处理
"""

View File

@@ -2,14 +2,12 @@ from pathlib import Path
from typing import Optional
from xml.dom import minidom
from app.core.config import settings
from app.core.context import MediaInfo
from app.schemas.types import MediaType
from app.utils.dom import DomUtils
class DoubanScraper:
_transfer_type = settings.TRANSFER_TYPE
_force_nfo = False
_force_img = False

View File

@@ -11,7 +11,6 @@ from app.utils.dom import DomUtils
class TmdbScraper:
tmdb = None
_transfer_type = settings.TRANSFER_TYPE
_force_nfo = False
_force_img = False

View File

@@ -5,11 +5,11 @@ from pywebpush import webpush, WebPushException
from app.core.config import global_vars, settings
from app.log import logger
from app.modules import _ModuleBase
from app.schemas import MessageChannel, Notification
from app.modules import _ModuleBase, _MessageBase
from app.schemas import Notification
class WebPushModule(_ModuleBase):
class WebPushModule(_ModuleBase, _MessageBase):
def init_module(self) -> None:
pass
@@ -27,9 +27,8 @@ class WebPushModule(_ModuleBase):
return True, ""
def init_setting(self) -> Tuple[str, Union[str, bool]]:
return "MESSAGER", "webpush"
pass
@checkMessage(MessageChannel.WebPush)
def post_message(self, message: Notification) -> None:
"""
发送消息
@@ -39,6 +38,9 @@ class WebPushModule(_ModuleBase):
if not message.title and not message.text:
logger.warn("标题和内容不能同时为空")
return
if not self.checkMessage(message):
logger.warn("WebPush 通道未启用")
return
try:
if message.title:
caption = message.title