summaryrefslogtreecommitdiff
path: root/ATRI/plugins/help/data_source.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/help/data_source.py')
-rw-r--r--ATRI/plugins/help/data_source.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/ATRI/plugins/help/data_source.py b/ATRI/plugins/help/data_source.py
index 930f4bb..831d1e0 100644
--- a/ATRI/plugins/help/data_source.py
+++ b/ATRI/plugins/help/data_source.py
@@ -24,10 +24,9 @@ COMMAND_INFO_FORMAT = """
class Helper(Service):
-
def __init__(self):
Service.__init__(self, "帮助", "bot的食用指南~")
-
+
@staticmethod
def menu() -> str:
return (
@@ -37,7 +36,7 @@ class Helper(Service):
"帮助 [服务] -以查看对应服务帮助\n"
"Tip: 均需要at触发。菜单 打开此页面"
)
-
+
@staticmethod
def about() -> str:
temp_list = list()
@@ -51,7 +50,7 @@ class Helper(Service):
"想进一步了解:\n"
"https://github.com/Kyomotoi/ATRI"
)
-
+
@staticmethod
def service_list() -> str:
files = os.listdir(SERVICES_DIR)
@@ -59,42 +58,42 @@ class Helper(Service):
for i in files:
service = i.replace(".json", "")
temp_list.append(service)
-
+
msg0 = "咱搭载了以下服务~\n"
services = " | ".join(map(str, temp_list))
msg0 = msg0 + services
repo = msg0 + "\n帮助 [服务] -以查看对应服务帮助"
return repo
-
+
@staticmethod
def service_info(service: str) -> str:
try:
data = ServiceTools().load_service(service)
except ReadFileError:
return "请检查是否输入错误呢..."
-
+
service_name = data.get("service", "error")
service_docs = data.get("docs", "error")
service_enabled = data.get("enabled", True)
-
+
_service_cmd_list = list(data.get("cmd_list", {"error"}))
service_cmd_list = "\n".join(map(str, _service_cmd_list))
-
+
repo = SERVICE_INFO_FORMAT.format(
service=service_name,
docs=service_docs,
cmd_list=service_cmd_list,
- enabled=service_enabled
+ enabled=service_enabled,
)
return repo
-
+
@staticmethod
def cmd_info(service: str, cmd: str) -> str:
try:
data = ServiceTools().load_service(service)
except ReadFileError:
return "请检查是否输入错误..."
-
+
cmd_list: dict = data["cmd_list"]
cmd_info = cmd_list.get(cmd, dict())
if not cmd_info:
@@ -102,11 +101,8 @@ class Helper(Service):
cmd_type = cmd_info.get("type", "ignore")
docs = cmd_info.get("docs", "ignore")
aliases = cmd_info.get("aliases", "ignore")
-
+
repo = COMMAND_INFO_FORMAT.format(
- cmd=cmd,
- cmd_type=cmd_type,
- docs=docs,
- aliases=aliases
+ cmd=cmd, cmd_type=cmd_type, docs=docs, aliases=aliases
)
return repo