mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-26 19:40:51 +08:00
增加通知标题
This commit is contained in:
@@ -32,7 +32,7 @@ class PostNotification:
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _gen_message(notify: Notification) -> str:
|
||||
def _gen_message(notify: Notification) -> (str, str):
|
||||
with BangumiDatabase() as db:
|
||||
poster_path = db.match_poster(notify.official_title)
|
||||
if poster_path:
|
||||
@@ -44,12 +44,14 @@ class PostNotification:
|
||||
text = f"""
|
||||
番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n
|
||||
"""
|
||||
return text
|
||||
|
||||
title = f"""{notify.official_title}S{notify.season}E{notify.episode}"""
|
||||
return text, title
|
||||
|
||||
def send_msg(self, notify: Notification) -> bool:
|
||||
text = self._gen_message(notify)
|
||||
text, title = self._gen_message(notify)
|
||||
try:
|
||||
self.notifier.post_msg(text)
|
||||
self.notifier.post_msg(text, title)
|
||||
logger.debug(f"Send notification: {notify.official_title}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to send notification: {e}")
|
||||
|
||||
@@ -11,8 +11,8 @@ class BarkNotification(RequestContent):
|
||||
self.token = token
|
||||
self.notification_url = "https://api.day.app/push"
|
||||
|
||||
def post_msg(self, text) -> bool:
|
||||
data = {"title": "AutoBangumi 番剧更新", "body": text, "device_key": self.token}
|
||||
def post_msg(self, text, title: str) -> bool:
|
||||
data = {"title": title, "body": text, "device_key": self.token}
|
||||
resp = self.post_data(self.notification_url, data)
|
||||
logger.debug(f"Bark notification: {resp.status_code}")
|
||||
return resp.status_code == 200
|
||||
|
||||
@@ -12,9 +12,9 @@ class ServerChanNotification(RequestContent):
|
||||
super().__init__()
|
||||
self.notification_url = f"https://sctapi.ftqq.com/{token}.send"
|
||||
|
||||
def post_msg(self, text: str) -> bool:
|
||||
def post_msg(self, text: str, title: str) -> bool:
|
||||
data = {
|
||||
"title": "AutoBangumi 番剧更新",
|
||||
"title": title,
|
||||
"desp": text,
|
||||
}
|
||||
resp = self.post_data(self.notification_url, data)
|
||||
|
||||
@@ -11,8 +11,8 @@ class SlackNotification(RequestContent):
|
||||
self.token = token
|
||||
self.notification_url = "https://api.day.app/push"
|
||||
|
||||
def post_msg(self, text) -> bool:
|
||||
data = {"title": "AutoBangumi 番剧更新", "body": text, "device_key": self.token}
|
||||
def post_msg(self, text: str, title: str) -> bool:
|
||||
data = {"title": title, "body": text, "device_key": self.token}
|
||||
resp = self.post_data(self.notification_url, data)
|
||||
logger.debug(f"Bark notification: {resp.status_code}")
|
||||
return resp.status_code == 200
|
||||
@@ -11,7 +11,7 @@ class TelegramNotification(RequestContent):
|
||||
self.notification_url = f"https://api.telegram.org/bot{token}/sendMessage"
|
||||
self.chat_id = chat_id
|
||||
|
||||
def post_msg(self, text: str) -> bool:
|
||||
def post_msg(self, text: str, title: str) -> bool:
|
||||
data = {
|
||||
"chat_id": self.chat_id,
|
||||
"text": text,
|
||||
|
||||
@@ -13,7 +13,7 @@ class WecomNotification(RequestContent):
|
||||
self.notification_url = f"{chat_id}"
|
||||
self.token = token
|
||||
|
||||
def post_msg(self, text: str) -> bool:
|
||||
def post_msg(self, text: str, title: str) -> bool:
|
||||
##Change message format to match Wecom push better
|
||||
info = text.split(":")
|
||||
print(info)
|
||||
@@ -24,10 +24,10 @@ class WecomNotification(RequestContent):
|
||||
if picurl == "":
|
||||
picurl = "https://article.biliimg.com/bfs/article/d8bcd0408bf32594fd82f27de7d2c685829d1b2e.png"
|
||||
data = {
|
||||
"key":self.token,
|
||||
"type": "news",
|
||||
"title": title,
|
||||
"msg": msg,
|
||||
"key":self.token,
|
||||
"type": "news",
|
||||
"title": title,
|
||||
"msg": msg,
|
||||
"picurl":picurl
|
||||
}
|
||||
resp = self.post_data(self.notification_url, data)
|
||||
|
||||
Reference in New Issue
Block a user