mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-20 03:57:30 +08:00
fix(telegram):优化消息发送错误日志记录
- 在 send_msg 方法中细化错误日志,明确指出发送失败的位置 - 在 send_medias_msg 方法中增加标题转义注释并调整日志描述 - 在 send_torrents_msg 方法中补充标题转义逻辑及错误日志说明
This commit is contained in:
@@ -276,7 +276,7 @@ class Telegram:
|
||||
return self.__send_request(userid=chat_id, image=image, caption=caption, reply_markup=reply_markup)
|
||||
|
||||
except Exception as msg_e:
|
||||
logger.error(f"发送消息失败:{msg_e}")
|
||||
logger.error(f"使用 send_msg 发送消息失败:{msg_e}")
|
||||
return False
|
||||
|
||||
def _determine_target_chat_id(self, userid: Optional[str] = None,
|
||||
@@ -322,6 +322,7 @@ class Telegram:
|
||||
|
||||
try:
|
||||
if title:
|
||||
# 标题总是转义(因为通常标题不包含Markdown格式)
|
||||
title = self.escape_markdown(title)
|
||||
index, image, caption = 1, "", "*%s*" % title
|
||||
for media in medias:
|
||||
@@ -362,7 +363,7 @@ class Telegram:
|
||||
return self.__send_request(userid=chat_id, image=image, caption=caption, reply_markup=reply_markup)
|
||||
|
||||
except Exception as msg_e:
|
||||
logger.error(f"发送消息失败:{msg_e}")
|
||||
logger.error(f"使用 send_medias_msg 发送消息失败:{msg_e}")
|
||||
return False
|
||||
|
||||
def send_torrents_msg(self, torrents: List[Context],
|
||||
@@ -385,6 +386,7 @@ class Telegram:
|
||||
|
||||
try:
|
||||
if title:
|
||||
# 标题总是转义(因为通常标题不包含Markdown格式)
|
||||
title = self.escape_markdown(title)
|
||||
index, caption = 1, "*%s*" % title
|
||||
image = torrents[0].media_info.get_message_image()
|
||||
@@ -424,7 +426,7 @@ class Telegram:
|
||||
return self.__send_request(userid=chat_id, image=image, caption=caption, reply_markup=reply_markup)
|
||||
|
||||
except Exception as msg_e:
|
||||
logger.error(f"发送消息失败:{msg_e}")
|
||||
logger.error(f"使用 send_torrents_msg 发送消息失败:{msg_e}")
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user