feat 多通知渠道支持
This commit is contained in:
@ -5,9 +5,9 @@ from typing import Optional, Union, List, Tuple, Any
|
||||
from app.core.context import MediaInfo, Context
|
||||
from app.core.config import settings
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules import _ModuleBase, checkMessage
|
||||
from app.modules.slack.slack import Slack
|
||||
from app.schemas import MessageChannel, CommingMessage
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
|
||||
|
||||
class SlackModule(_ModuleBase):
|
||||
@ -181,40 +181,33 @@ class SlackModule(_ModuleBase):
|
||||
userid=userid, username=username, text=text)
|
||||
return None
|
||||
|
||||
def post_message(self, title: str,
|
||||
text: str = None, image: str = None,
|
||||
userid: Union[str, int] = None) -> Optional[bool]:
|
||||
@checkMessage(MessageChannel.Slack)
|
||||
def post_message(self, message: Notification) -> Optional[bool]:
|
||||
"""
|
||||
发送消息
|
||||
:param title: 标题
|
||||
:param text: 内容
|
||||
:param image: 图片
|
||||
:param userid: 用户ID
|
||||
:param message: 消息
|
||||
:return: 成功或失败
|
||||
"""
|
||||
return self.slack.send_msg(title=title, text=text, image=image, userid=userid)
|
||||
return self.slack.send_msg(title=message.title, text=message.text,
|
||||
image=message.image, userid=message.userid)
|
||||
|
||||
def post_medias_message(self, title: str, items: List[MediaInfo],
|
||||
userid: Union[str, int] = None) -> Optional[bool]:
|
||||
@checkMessage(MessageChannel.Slack)
|
||||
def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]:
|
||||
"""
|
||||
发送媒体信息选择列表
|
||||
:param title: 标题
|
||||
:param items: 消息列表
|
||||
:param userid: 用户ID
|
||||
:param message: 消息体
|
||||
:param medias: 媒体信息
|
||||
:return: 成功或失败
|
||||
"""
|
||||
return self.slack.send_meidas_msg(title=title, medias=items, userid=userid)
|
||||
return self.slack.send_meidas_msg(title=message.title, medias=medias, userid=message.userid)
|
||||
|
||||
def post_torrents_message(self, title: str, items: List[Context],
|
||||
mediainfo: MediaInfo = None,
|
||||
userid: Union[str, int] = None) -> Optional[bool]:
|
||||
@checkMessage(MessageChannel.Slack)
|
||||
def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]:
|
||||
"""
|
||||
发送种子信息选择列表
|
||||
:param title: 标题
|
||||
:param items: 消息列表
|
||||
:param mediainfo: 媒体信息
|
||||
:param userid: 用户ID
|
||||
:param message: 消息体
|
||||
:param torrents: 种子信息
|
||||
:return: 成功或失败
|
||||
"""
|
||||
return self.slack.send_torrents_msg(title=title, torrents=items,
|
||||
userid=userid)
|
||||
return self.slack.send_torrents_msg(title=message.title, torrents=torrents,
|
||||
userid=message.userid)
|
||||
|
Reference in New Issue
Block a user