fix: tg notification

This commit is contained in:
EstrellaXD
2023-10-04 17:55:19 +08:00
parent 354dc8f694
commit babedf5d15
4 changed files with 14 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import logging
from module.models import Notification
from module.network import RequestContent
from module.utils import load_image
logger = logging.getLogger(__name__)
@@ -24,9 +25,14 @@ class TelegramNotification(RequestContent):
data = {
"chat_id": self.chat_id,
"caption": text,
"photo": notify.poster_path,
"disable_notification": True,
}
resp = self.post_data(self.notification_url, data)
photo = load_image(notify.poster_path)
if photo:
resp = self.post_form(
self.notification_url, data, files={"photo": photo}
)
else:
resp = self.post_data(self.notification_url, data)
logger.debug(f"Telegram notification: {resp.status_code}")
return resp.status_code == 200