From 10a15d7b2def14721c81c35da2869f359fd53623 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 12 Apr 2024 11:49:19 +0800 Subject: [PATCH] fix --- plugins/ntfymsg/__init__.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/ntfymsg/__init__.py b/plugins/ntfymsg/__init__.py index d33ef61..c005233 100644 --- a/plugins/ntfymsg/__init__.py +++ b/plugins/ntfymsg/__init__.py @@ -1,4 +1,5 @@ -import json, requests +import json +import requests from typing import Any, List, Dict, Tuple @@ -7,6 +8,7 @@ from app.log import logger from app.plugins import _PluginBase from app.schemas.types import EventType, NotificationType + class NtfyClient: def send(self, message: str, title: str = None, format_as_markdown: bool = False): @@ -21,19 +23,21 @@ class NtfyClient: return response def __init__( - self, - topic: str, - server: str = "https://ntfy.sh", - user: str = "", - password: str = "", + self, + topic: str, + server: str = "https://ntfy.sh", + user: str = "", + password: str = "", ): self._server = server self._topic = topic self.__set_url(server, topic) self._auth = (user, password) + def __set_url(self, server, topic): self.url = server.strip("/") + "/" + topic + class NtfyMsg(_PluginBase): # 插件名称 plugin_name = "ntfy 消息通知" @@ -220,11 +224,10 @@ class NtfyMsg(_PluginBase): 'msgtypes': [], 'server': 'https://ntfy.sh', 'topic': 'MoviePilot', - 'user':'', - 'password':'', + 'user': '', + 'password': '', } - def get_page(self) -> List[dict]: pass @@ -264,7 +267,7 @@ class NtfyMsg(_PluginBase): if not self._server or not self._topic: return False, "参数未配置" ntfy = NtfyClient(server=self._server, topic=self._topic, user=self._user, password=self._password) - ntfy.send(title=title, message=text,format_as_markdown=True) + ntfy.send(title=title, message=text, format_as_markdown=True) except Exception as msg_e: logger.error(f"ntfy消息发送失败,错误信息:{str(msg_e)}")