From 664a121092aec146283b2b1309aa601f79635a96 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Thu, 5 Oct 2023 15:03:50 +0800 Subject: [PATCH] fix: telegram photo error. --- 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 6f22056b..ac35623d 100644 --- a/backend/src/module/notification/plugin/telegram.py +++ b/backend/src/module/notification/plugin/telegram.py @@ -10,7 +10,8 @@ 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}/sendPhoto" + self.photo_url = f"https://api.telegram.org/bot{token}/sendPhoto" + self.message_url = f"https://api.telegram.org/bot{token}/sendMessage" self.chat_id = chat_id @staticmethod @@ -30,9 +31,9 @@ class TelegramNotification(RequestContent): photo = load_image(notify.poster_path) if photo: resp = self.post_files( - self.notification_url, data, files={"photo": photo} + self.photo_url, data, files={"photo": photo} ) else: - resp = self.post_data(self.notification_url, data) + resp = self.post_data(self.message_url, data) logger.debug(f"Telegram notification: {resp.status_code}") return resp.status_code == 200