feat:模块健康检查

This commit is contained in:
jxxghp
2024-03-06 13:23:51 +08:00
parent 01e08c8e69
commit 8cb061ff75
24 changed files with 248 additions and 28 deletions

View File

@ -19,6 +19,15 @@ class SlackModule(_ModuleBase):
def stop(self):
self.slack.stop()
def test(self) -> Tuple[bool, str]:
"""
测试模块连接性
"""
state = self.slack.get_state()
if state:
return True, ""
return False, "Slack未就续请检查参数设置和网络连接"
def init_setting(self) -> Tuple[str, Union[str, bool]]:
return "MESSAGER", "slack"

View File

@ -87,6 +87,12 @@ class Slack:
except Exception as err:
logger.error("Slack消息接收服务停止失败: %s" % str(err))
def get_state(self) -> bool:
"""
获取状态
"""
return True if self._client else False
def send_msg(self, title: str, text: str = "", image: str = "", url: str = "", userid: str = ""):
"""
发送Telegram消息