From 7e46538d796e8891299cf422e1e3811016cffc92 Mon Sep 17 00:00:00 2001 From: shininome Date: Mon, 2 Oct 2023 12:54:16 +0800 Subject: [PATCH] change sendmessage to sendphoto(more like nastool --- backend/src/module/notification/plugin/telegram.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/module/notification/plugin/telegram.py b/backend/src/module/notification/plugin/telegram.py index 717f265b..36e6672e 100644 --- a/backend/src/module/notification/plugin/telegram.py +++ b/backend/src/module/notification/plugin/telegram.py @@ -9,13 +9,13 @@ logger = logging.getLogger(__name__) class TelegramNotification(RequestContent): def __init__(self, token, chat_id): super().__init__() - self.notification_url = f"https://api.telegram.org/bot{token}/sendMessage" + self.notification_url = f"https://api.telegram.org/bot{token}/sendPhoto" self.chat_id = chat_id @staticmethod def gen_message(notify: Notification) -> str: text = f""" - 番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n{notify.poster_path}\n + 番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集 """ return text @@ -23,7 +23,8 @@ class TelegramNotification(RequestContent): text = self.gen_message(notify) data = { "chat_id": self.chat_id, - "text": text, + "caption": text, + "photo": notify.poster_path, "disable_notification": True, } resp = self.post_data(self.notification_url, data)