Skip to content

Commit

Permalink
fix #2515
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Jul 16, 2024
1 parent 71260f0 commit 3352573
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/modules/telegram/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def send_msg(self, title: str, text: str = "", image: str = "",

try:
if text:
# 对text进行Markdown特殊字符转义
text = re.sub(r"([_`])", r"\\\1", text)
caption = f"*{title}*\n{text}"
else:
caption = f"*{title}*"
Expand Down Expand Up @@ -208,8 +210,6 @@ def __send_request(self, userid: str = None, image="", caption="") -> bool:
image_file = Path(settings.TEMP_PATH) / str(uuid.uuid4())
image_file.write_bytes(res.content)
photo = InputFile(image_file)
# 对caption进行Markdown特殊字符转义
caption = re.sub(r"([_`])", r"\\\1", caption)
# 发送图片到Telegram
ret = self._bot.send_photo(chat_id=userid or self._telegram_chat_id,
photo=photo,
Expand Down

0 comments on commit 3352573

Please sign in to comment.