add notification link
This commit is contained in:
@ -110,7 +110,7 @@ class TelegramModule(_ModuleBase):
|
||||
:return: 成功或失败
|
||||
"""
|
||||
self.telegram.send_msg(title=message.title, text=message.text,
|
||||
image=message.image, userid=message.userid)
|
||||
image=message.image, userid=message.userid, link=message.link)
|
||||
|
||||
@checkMessage(MessageChannel.Telegram)
|
||||
def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]:
|
||||
@ -121,7 +121,7 @@ class TelegramModule(_ModuleBase):
|
||||
:return: 成功或失败
|
||||
"""
|
||||
return self.telegram.send_meidas_msg(title=message.title, medias=medias,
|
||||
userid=message.userid)
|
||||
userid=message.userid, link=message.link)
|
||||
|
||||
@checkMessage(MessageChannel.Telegram)
|
||||
def post_torrents_message(self, message: Notification, torrents: List[Context]) -> Optional[bool]:
|
||||
@ -131,7 +131,8 @@ class TelegramModule(_ModuleBase):
|
||||
:param torrents: 种子列表
|
||||
:return: 成功或失败
|
||||
"""
|
||||
return self.telegram.send_torrents_msg(title=message.title, torrents=torrents, userid=message.userid)
|
||||
return self.telegram.send_torrents_msg(title=message.title, torrents=torrents,
|
||||
userid=message.userid, link=message.link)
|
||||
|
||||
def register_commands(self, commands: Dict[str, dict]):
|
||||
"""
|
||||
|
@ -67,13 +67,15 @@ class Telegram:
|
||||
"""
|
||||
return self._bot is not None
|
||||
|
||||
def send_msg(self, title: str, text: str = "", image: str = "", userid: str = "") -> Optional[bool]:
|
||||
def send_msg(self, title: str, text: str = "", image: str = "",
|
||||
userid: str = "", link: str = None) -> Optional[bool]:
|
||||
"""
|
||||
发送Telegram消息
|
||||
:param title: 消息标题
|
||||
:param text: 消息内容
|
||||
:param image: 消息图片地址
|
||||
:param userid: 用户ID,如有则只发消息给该用户
|
||||
:param link: 跳转链接
|
||||
:userid: 发送消息的目标用户ID,为空则发给管理员
|
||||
"""
|
||||
if not self._telegram_token or not self._telegram_chat_id:
|
||||
@ -89,6 +91,9 @@ class Telegram:
|
||||
else:
|
||||
caption = f"*{title}*"
|
||||
|
||||
if link:
|
||||
caption = f"{caption}\n[查看详情]({link})"
|
||||
|
||||
if userid:
|
||||
chat_id = userid
|
||||
else:
|
||||
@ -100,7 +105,8 @@ class Telegram:
|
||||
logger.error(f"发送消息失败:{msg_e}")
|
||||
return False
|
||||
|
||||
def send_meidas_msg(self, medias: List[MediaInfo], userid: str = "", title: str = "") -> Optional[bool]:
|
||||
def send_meidas_msg(self, medias: List[MediaInfo], userid: str = "",
|
||||
title: str = "", link: str = None) -> Optional[bool]:
|
||||
"""
|
||||
发送媒体列表消息
|
||||
"""
|
||||
@ -127,6 +133,9 @@ class Telegram:
|
||||
f"类型:{media.type.value}")
|
||||
index += 1
|
||||
|
||||
if link:
|
||||
caption = f"{caption}\n[查看详情]({link})"
|
||||
|
||||
if userid:
|
||||
chat_id = userid
|
||||
else:
|
||||
@ -139,7 +148,7 @@ class Telegram:
|
||||
return False
|
||||
|
||||
def send_torrents_msg(self, torrents: List[Context],
|
||||
userid: str = "", title: str = "") -> Optional[bool]:
|
||||
userid: str = "", title: str = "", link: str = None) -> Optional[bool]:
|
||||
"""
|
||||
发送列表消息
|
||||
"""
|
||||
@ -168,6 +177,9 @@ class Telegram:
|
||||
f"{StringUtils.str_filesize(torrent.size)} {free} {seeder}"
|
||||
index += 1
|
||||
|
||||
if link:
|
||||
caption = f"{caption}\n[查看详情]({link})"
|
||||
|
||||
if userid:
|
||||
chat_id = userid
|
||||
else:
|
||||
|
Reference in New Issue
Block a user