ErisPulse-HelpModule 2.1.1__tar.gz → 2.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule/Core.py +17 -3
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule/templates.py +201 -120
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/PKG-INFO +1 -1
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/PKG-INFO +1 -1
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/pyproject.toml +1 -1
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule/__init__.py +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/SOURCES.txt +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/dependency_links.txt +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/entry_points.txt +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/top_level.txt +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/LICENSE +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/README.md +0 -0
- {erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/setup.cfg +0 -0
|
@@ -38,10 +38,19 @@ class HelpModule(BaseModule):
|
|
|
38
38
|
return default_config
|
|
39
39
|
return module_config
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def _get_all_prefixes(self) -> list:
|
|
42
|
+
"""获取所有命令前缀列表"""
|
|
42
43
|
event_config = config.getConfig("ErisPulse.event", {})
|
|
43
44
|
command_config = event_config.get("command", {})
|
|
44
|
-
|
|
45
|
+
prefix = command_config.get("prefix", "/")
|
|
46
|
+
if isinstance(prefix, list):
|
|
47
|
+
return [str(p) for p in prefix] if prefix else ["/"]
|
|
48
|
+
return [str(prefix)]
|
|
49
|
+
|
|
50
|
+
def _get_command_prefix(self) -> str:
|
|
51
|
+
"""获取主显示前缀(第一个)"""
|
|
52
|
+
prefixes = self._get_all_prefixes()
|
|
53
|
+
return prefixes[0] if prefixes else "/"
|
|
45
54
|
|
|
46
55
|
def _register_commands(self):
|
|
47
56
|
self.help_command_func = self._create_help_command()
|
|
@@ -99,6 +108,8 @@ class HelpModule(BaseModule):
|
|
|
99
108
|
commands = self._build_command_list()
|
|
100
109
|
module_config = self._get_config()
|
|
101
110
|
|
|
111
|
+
prefixes = self._get_all_prefixes()
|
|
112
|
+
|
|
102
113
|
if args:
|
|
103
114
|
# 显示命令详情
|
|
104
115
|
try:
|
|
@@ -106,7 +117,9 @@ class HelpModule(BaseModule):
|
|
|
106
117
|
if index in self.command_map:
|
|
107
118
|
# 使用模板构建命令详情
|
|
108
119
|
templates = HelpTemplates.build_command_detail(
|
|
109
|
-
self.command_map[index],
|
|
120
|
+
self.command_map[index],
|
|
121
|
+
self._get_command_prefix(),
|
|
122
|
+
prefixes,
|
|
110
123
|
)
|
|
111
124
|
else:
|
|
112
125
|
# 使用错误模板
|
|
@@ -124,6 +137,7 @@ class HelpModule(BaseModule):
|
|
|
124
137
|
self.command_map,
|
|
125
138
|
self._get_command_prefix(),
|
|
126
139
|
module_config.get("group_commands", True),
|
|
140
|
+
prefixes,
|
|
127
141
|
)
|
|
128
142
|
|
|
129
143
|
# 根据平台能力选择最佳格式,通过 event.reply 发送
|
|
@@ -2,50 +2,95 @@
|
|
|
2
2
|
帮助模块模板系统
|
|
3
3
|
提供多平台支持的消息模板
|
|
4
4
|
"""
|
|
5
|
+
|
|
5
6
|
from typing import Dict, List, Optional
|
|
7
|
+
|
|
6
8
|
from ErisPulse.Core.Event import command
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class HelpTemplates:
|
|
10
12
|
"""帮助模块模板类"""
|
|
11
|
-
|
|
13
|
+
|
|
12
14
|
# 配色方案
|
|
13
15
|
PRIMARY_COLOR = "#1565c0" # 蓝色 - 主标题
|
|
14
16
|
SUCCESS_COLOR = "#2e7d32" # 绿色 - 成功信息
|
|
15
17
|
WARNING_COLOR = "#e65100" # 橙色 - 警告信息
|
|
16
|
-
ERROR_COLOR = "#b71c1c"
|
|
17
|
-
|
|
18
|
+
ERROR_COLOR = "#b71c1c" # 红色 - 错误信息
|
|
19
|
+
|
|
18
20
|
# 半透明背景色
|
|
19
21
|
PRIMARY_BG = "rgba(21, 101, 192, 0.05)"
|
|
20
22
|
SUCCESS_BG = "rgba(76, 175, 80, 0.1)"
|
|
21
23
|
WARNING_BG = "rgba(255, 167, 38, 0.15)"
|
|
22
24
|
ERROR_BG = "rgba(183, 28, 28, 0.1)"
|
|
23
|
-
|
|
25
|
+
|
|
24
26
|
@classmethod
|
|
25
27
|
def _get_group_name(cls, group: str) -> str:
|
|
26
28
|
if group == "default":
|
|
27
29
|
return "通用命令"
|
|
28
30
|
return f"{group}命令" if group else "其他"
|
|
29
|
-
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
def _other_prefixes(cls, prefixes: list, display_prefix: str) -> list:
|
|
34
|
+
"""获取除主前缀外的其他前缀"""
|
|
35
|
+
if not prefixes or len(prefixes) <= 1:
|
|
36
|
+
return []
|
|
37
|
+
return [p for p in prefixes if p != display_prefix]
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def _prefix_note_html(cls, other_prefixes: list) -> str:
|
|
41
|
+
if not other_prefixes:
|
|
42
|
+
return ""
|
|
43
|
+
note = "、".join(
|
|
44
|
+
f"<code style='font-size:11px;'>{p}</code>" for p in other_prefixes
|
|
45
|
+
)
|
|
46
|
+
return f'<div style="font-size: 11px; color: #999; margin-top: 4px;">其他触发前缀: {note}</div>'
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def _prefix_note_text(cls, other_prefixes: list) -> str:
|
|
50
|
+
if not other_prefixes:
|
|
51
|
+
return ""
|
|
52
|
+
note = "、".join(other_prefixes)
|
|
53
|
+
return f"\n其他触发前缀: {note}"
|
|
54
|
+
|
|
30
55
|
# ==================== 帮助列表模板 ====================
|
|
31
|
-
|
|
56
|
+
|
|
32
57
|
@classmethod
|
|
33
|
-
def build_help_list(
|
|
34
|
-
|
|
58
|
+
def build_help_list(
|
|
59
|
+
cls,
|
|
60
|
+
commands: List[Dict],
|
|
61
|
+
command_map: Dict[int, Dict],
|
|
62
|
+
prefix: str,
|
|
63
|
+
group_commands: bool = True,
|
|
64
|
+
prefixes: Optional[list] = None,
|
|
65
|
+
) -> Dict[str, str]:
|
|
66
|
+
other_prefixes = cls._other_prefixes(prefixes or [prefix], prefix)
|
|
67
|
+
|
|
35
68
|
# 构建 HTML
|
|
36
|
-
html = cls._build_help_list_html(
|
|
37
|
-
|
|
69
|
+
html = cls._build_help_list_html(
|
|
70
|
+
commands, command_map, prefix, group_commands, other_prefixes
|
|
71
|
+
)
|
|
72
|
+
|
|
38
73
|
# 构建 Markdown
|
|
39
|
-
markdown = cls._build_help_list_markdown(
|
|
40
|
-
|
|
74
|
+
markdown = cls._build_help_list_markdown(
|
|
75
|
+
commands, command_map, prefix, group_commands, other_prefixes
|
|
76
|
+
)
|
|
77
|
+
|
|
41
78
|
# 构建 Text
|
|
42
|
-
text = cls._build_help_list_text(
|
|
43
|
-
|
|
79
|
+
text = cls._build_help_list_text(
|
|
80
|
+
commands, command_map, prefix, group_commands, other_prefixes
|
|
81
|
+
)
|
|
82
|
+
|
|
44
83
|
return {"html": html, "markdown": markdown, "text": text}
|
|
45
|
-
|
|
84
|
+
|
|
46
85
|
@classmethod
|
|
47
|
-
def _build_help_list_html(
|
|
48
|
-
|
|
86
|
+
def _build_help_list_html(
|
|
87
|
+
cls,
|
|
88
|
+
commands: List[Dict],
|
|
89
|
+
command_map: Dict[int, Dict],
|
|
90
|
+
prefix: str,
|
|
91
|
+
group_commands: bool,
|
|
92
|
+
other_prefixes: Optional[list] = None,
|
|
93
|
+
) -> str:
|
|
49
94
|
# 重置命令映射
|
|
50
95
|
grouped = {}
|
|
51
96
|
if group_commands:
|
|
@@ -56,27 +101,27 @@ class HelpTemplates:
|
|
|
56
101
|
grouped[group].append(cmd)
|
|
57
102
|
else:
|
|
58
103
|
grouped["default"] = commands
|
|
59
|
-
|
|
104
|
+
|
|
60
105
|
# 构建命令列表 HTML(带展开/折叠功能)
|
|
61
106
|
commands_html = ""
|
|
62
107
|
global_idx = 1
|
|
63
|
-
|
|
108
|
+
|
|
64
109
|
for group, cmds in grouped.items():
|
|
65
110
|
group_name = cls._get_group_name(group)
|
|
66
|
-
|
|
111
|
+
|
|
67
112
|
commands_html += f"""
|
|
68
113
|
<div style="font-size:13px; margin-bottom: 8px; font-weight: bold; color: {cls.PRIMARY_COLOR};">{group_name}</div>
|
|
69
114
|
"""
|
|
70
|
-
|
|
115
|
+
|
|
71
116
|
for cmd in cmds:
|
|
72
117
|
name = cmd["name"]
|
|
73
118
|
info = cmd["info"]
|
|
74
119
|
help_text = info.get("help", "暂无描述")
|
|
75
120
|
command_map[global_idx] = cmd
|
|
76
|
-
|
|
121
|
+
|
|
77
122
|
# 构建命令详情内容
|
|
78
123
|
detail_content = cls._build_command_detail_inline(name, info, prefix)
|
|
79
|
-
|
|
124
|
+
|
|
80
125
|
commands_html += f"""<details style="margin-bottom: 8px;">
|
|
81
126
|
<summary style="cursor: pointer; font-size: 13px; padding: 4px; background: rgba(0, 0, 0, 0.02); border-radius: 4px; display: flex; align-items: center;">
|
|
82
127
|
<span style="font-weight: bold; margin-right: 8px;">{global_idx}.</span>
|
|
@@ -87,43 +132,45 @@ class HelpTemplates:
|
|
|
87
132
|
{detail_content}
|
|
88
133
|
</div>
|
|
89
134
|
</details>"""
|
|
90
|
-
global_idx +=1
|
|
91
|
-
|
|
135
|
+
global_idx += 1
|
|
136
|
+
|
|
92
137
|
commands_html += "\n"
|
|
93
|
-
|
|
138
|
+
|
|
94
139
|
# 构建完整 HTML
|
|
95
140
|
html = f"""<div style="padding: 12px; border-radius: 8px;">
|
|
96
141
|
<div style="color: {cls.PRIMARY_COLOR}; font-size: 16px; font-weight: bold; margin-bottom: 12px;">
|
|
97
142
|
命令帮助
|
|
98
143
|
</div>
|
|
99
|
-
|
|
144
|
+
|
|
100
145
|
<div style="padding: 8px; background: {cls.PRIMARY_BG}; border-radius: 6px; margin-bottom: 12px;">
|
|
101
146
|
<div style="font-size: 13px;">
|
|
102
147
|
使用 '{prefix}help <序号>' 查看命令详情
|
|
103
148
|
</div>
|
|
104
149
|
</div>
|
|
105
|
-
|
|
150
|
+
|
|
106
151
|
{commands_html}
|
|
107
|
-
|
|
152
|
+
|
|
108
153
|
<div style="font-size: 12px; color: #666; margin-top: 8px;">
|
|
109
154
|
共 {len(commands)} 个可用命令
|
|
110
155
|
</div>
|
|
156
|
+
{cls._prefix_note_html(other_prefixes or [])}
|
|
111
157
|
</div>"""
|
|
112
|
-
|
|
158
|
+
|
|
113
159
|
return html
|
|
114
|
-
|
|
160
|
+
|
|
115
161
|
@classmethod
|
|
116
|
-
def _build_help_list_markdown(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
162
|
+
def _build_help_list_markdown(
|
|
163
|
+
cls,
|
|
164
|
+
commands: List[Dict],
|
|
165
|
+
command_map: Dict[int, Dict],
|
|
166
|
+
prefix: str,
|
|
167
|
+
group_commands: bool,
|
|
168
|
+
other_prefixes: Optional[list] = None,
|
|
169
|
+
) -> str:
|
|
170
|
+
lines = ["**命令帮助**", "", f"使用 `{prefix}help <序号>` 查看命令详情", ""]
|
|
171
|
+
|
|
125
172
|
global_idx = 1
|
|
126
|
-
|
|
173
|
+
|
|
127
174
|
if group_commands:
|
|
128
175
|
grouped = {}
|
|
129
176
|
for cmd in commands:
|
|
@@ -131,19 +178,19 @@ class HelpTemplates:
|
|
|
131
178
|
if group not in grouped:
|
|
132
179
|
grouped[group] = []
|
|
133
180
|
grouped[group].append(cmd)
|
|
134
|
-
|
|
181
|
+
|
|
135
182
|
for group, cmds in grouped.items():
|
|
136
183
|
group_name = cls._get_group_name(group)
|
|
137
184
|
lines.append(f"**{group_name}**")
|
|
138
185
|
lines.append("")
|
|
139
|
-
|
|
186
|
+
|
|
140
187
|
for cmd in cmds:
|
|
141
188
|
name = cmd["name"]
|
|
142
189
|
help_text = cmd["info"].get("help", "暂无描述")
|
|
143
190
|
command_map[global_idx] = cmd
|
|
144
191
|
lines.append(f"{global_idx}. `{prefix}{name}` - {help_text}")
|
|
145
192
|
global_idx += 1
|
|
146
|
-
|
|
193
|
+
|
|
147
194
|
lines.append("")
|
|
148
195
|
else:
|
|
149
196
|
lines.append("**所有命令**")
|
|
@@ -155,24 +202,33 @@ class HelpTemplates:
|
|
|
155
202
|
lines.append(f"{global_idx}. `{prefix}{name}` - {help_text}")
|
|
156
203
|
global_idx += 1
|
|
157
204
|
lines.append("")
|
|
158
|
-
|
|
205
|
+
|
|
159
206
|
lines.append("---")
|
|
160
207
|
lines.append(f"共 {len(commands)} 个可用命令")
|
|
161
|
-
|
|
208
|
+
if other_prefixes:
|
|
209
|
+
lines.append("")
|
|
210
|
+
lines.append(f"其他触发前缀: {'、'.join(other_prefixes)}")
|
|
211
|
+
|
|
162
212
|
return "\n".join(lines)
|
|
163
|
-
|
|
213
|
+
|
|
164
214
|
@classmethod
|
|
165
|
-
def _build_help_list_text(
|
|
166
|
-
|
|
215
|
+
def _build_help_list_text(
|
|
216
|
+
cls,
|
|
217
|
+
commands: List[Dict],
|
|
218
|
+
command_map: Dict[int, Dict],
|
|
219
|
+
prefix: str,
|
|
220
|
+
group_commands: bool,
|
|
221
|
+
other_prefixes: Optional[list] = None,
|
|
222
|
+
) -> str:
|
|
167
223
|
lines = [
|
|
168
224
|
"命令帮助",
|
|
169
225
|
"----------",
|
|
170
226
|
f"使用 '{prefix}help <序号>' 查看命令详情",
|
|
171
|
-
""
|
|
227
|
+
"",
|
|
172
228
|
]
|
|
173
|
-
|
|
229
|
+
|
|
174
230
|
global_idx = 1
|
|
175
|
-
|
|
231
|
+
|
|
176
232
|
if group_commands:
|
|
177
233
|
grouped = {}
|
|
178
234
|
for cmd in commands:
|
|
@@ -180,19 +236,19 @@ class HelpTemplates:
|
|
|
180
236
|
if group not in grouped:
|
|
181
237
|
grouped[group] = []
|
|
182
238
|
grouped[group].append(cmd)
|
|
183
|
-
|
|
239
|
+
|
|
184
240
|
for group, cmds in grouped.items():
|
|
185
241
|
group_name = cls._get_group_name(group)
|
|
186
242
|
lines.append(f"[{group_name}]")
|
|
187
243
|
lines.append("")
|
|
188
|
-
|
|
244
|
+
|
|
189
245
|
for cmd in cmds:
|
|
190
246
|
name = cmd["name"]
|
|
191
247
|
help_text = cmd["info"].get("help", "暂无描述")
|
|
192
248
|
command_map[global_idx] = cmd
|
|
193
249
|
lines.append(f"{global_idx}. {prefix}{name} - {help_text}")
|
|
194
250
|
global_idx += 1
|
|
195
|
-
|
|
251
|
+
|
|
196
252
|
lines.append("")
|
|
197
253
|
else:
|
|
198
254
|
lines.append("[所有命令]")
|
|
@@ -204,53 +260,58 @@ class HelpTemplates:
|
|
|
204
260
|
lines.append(f"{global_idx}. {prefix}{name} - {help_text}")
|
|
205
261
|
global_idx += 1
|
|
206
262
|
lines.append("")
|
|
207
|
-
|
|
263
|
+
|
|
208
264
|
lines.append("----------")
|
|
209
265
|
lines.append(f"共 {len(commands)} 个可用命令")
|
|
210
|
-
|
|
266
|
+
if other_prefixes:
|
|
267
|
+
lines.append("")
|
|
268
|
+
lines.append(f"其他触发前缀: {'、'.join(other_prefixes)}")
|
|
269
|
+
|
|
211
270
|
return "\n".join(lines)
|
|
212
|
-
|
|
271
|
+
|
|
213
272
|
@classmethod
|
|
214
273
|
def _build_command_detail_inline(cls, name: str, info: Dict, prefix: str) -> str:
|
|
215
274
|
"""
|
|
216
275
|
构建内联命令详情(用于展开区域)
|
|
217
276
|
"""
|
|
218
277
|
parts = []
|
|
219
|
-
|
|
278
|
+
|
|
220
279
|
# 描述
|
|
221
280
|
parts.append(f"""<div style="margin-bottom: 8px;">
|
|
222
281
|
<strong style="font-size: 12px; color: {cls.PRIMARY_COLOR};">描述:</strong>
|
|
223
|
-
<span style="font-size: 12px; margin-left: 8px;">{info.get(
|
|
282
|
+
<span style="font-size: 12px; margin-left: 8px;">{info.get("help", "暂无描述")}</span>
|
|
224
283
|
</div>""")
|
|
225
|
-
|
|
284
|
+
|
|
226
285
|
# 别名 - 从全局 command.aliases 获取
|
|
227
|
-
main_name = info.get(
|
|
286
|
+
main_name = info.get("main_name", name)
|
|
228
287
|
aliases = []
|
|
229
288
|
for alias, mapped_name in command.aliases.items():
|
|
230
289
|
if mapped_name == main_name and alias != main_name:
|
|
231
290
|
aliases.append(alias)
|
|
232
|
-
|
|
291
|
+
|
|
233
292
|
if aliases:
|
|
234
|
-
aliases_text = ", ".join(
|
|
293
|
+
aliases_text = ", ".join(
|
|
294
|
+
f"<code style='font-size: 11px;'>{prefix}{a}</code>" for a in aliases
|
|
295
|
+
)
|
|
235
296
|
parts.append(f"""<div style="margin-bottom: 8px;">
|
|
236
297
|
<strong style="font-size: 12px; color: {cls.PRIMARY_COLOR};">别名:</strong>
|
|
237
298
|
<span style="font-size: 12px; margin-left: 8px;">{aliases_text}</span>
|
|
238
299
|
</div>""")
|
|
239
|
-
|
|
300
|
+
|
|
240
301
|
# 用法
|
|
241
302
|
if info.get("usage"):
|
|
242
303
|
parts.append(f"""<div style="margin-bottom: 8px;">
|
|
243
304
|
<strong style="font-size: 12px; color: {cls.PRIMARY_COLOR};">用法:</strong>
|
|
244
|
-
<span style="font-size: 12px; margin-left: 8px; font-family: monospace; background: rgba(0, 0, 0, 0.03); padding: 2px 6px; border-radius: 3px;">{info[
|
|
305
|
+
<span style="font-size: 12px; margin-left: 8px; font-family: monospace; background: rgba(0, 0, 0, 0.03); padding: 2px 6px; border-radius: 3px;">{info["usage"].replace("/", prefix)}</span>
|
|
245
306
|
</div>""")
|
|
246
|
-
|
|
307
|
+
|
|
247
308
|
# 权限
|
|
248
309
|
if info.get("permission"):
|
|
249
310
|
parts.append(f"""<div style="margin-bottom: 8px;">
|
|
250
311
|
<strong style="font-size: 12px; color: {cls.PRIMARY_COLOR};">权限:</strong>
|
|
251
312
|
<span style="font-size: 12px; margin-left: 8px; color: {cls.WARNING_COLOR};">需要特殊权限</span>
|
|
252
313
|
</div>""")
|
|
253
|
-
|
|
314
|
+
|
|
254
315
|
# 分组
|
|
255
316
|
if info.get("group"):
|
|
256
317
|
group_name = cls._get_group_name(info["group"])
|
|
@@ -258,36 +319,42 @@ class HelpTemplates:
|
|
|
258
319
|
<strong style="font-size: 12px; color: {cls.PRIMARY_COLOR};">分组:</strong>
|
|
259
320
|
<span style="font-size: 12px; margin-left: 8px;">{group_name}</span>
|
|
260
321
|
</div>""")
|
|
261
|
-
|
|
322
|
+
|
|
262
323
|
return "\n".join(parts)
|
|
263
|
-
|
|
324
|
+
|
|
264
325
|
# ==================== 命令详情模板 ====================
|
|
265
|
-
|
|
326
|
+
|
|
266
327
|
@classmethod
|
|
267
|
-
def build_command_detail(
|
|
328
|
+
def build_command_detail(
|
|
329
|
+
cls, cmd: Dict, prefix: str, prefixes: Optional[list] = None
|
|
330
|
+
) -> Dict[str, str]:
|
|
331
|
+
other_prefixes = cls._other_prefixes(prefixes or [prefix], prefix)
|
|
332
|
+
|
|
268
333
|
# 构建 HTML
|
|
269
|
-
html = cls._build_command_detail_html(cmd, prefix)
|
|
270
|
-
|
|
334
|
+
html = cls._build_command_detail_html(cmd, prefix, other_prefixes)
|
|
335
|
+
|
|
271
336
|
# 构建 Markdown
|
|
272
|
-
markdown = cls._build_command_detail_markdown(cmd, prefix)
|
|
273
|
-
|
|
337
|
+
markdown = cls._build_command_detail_markdown(cmd, prefix, other_prefixes)
|
|
338
|
+
|
|
274
339
|
# 构建 Text
|
|
275
|
-
text = cls._build_command_detail_text(cmd, prefix)
|
|
276
|
-
|
|
340
|
+
text = cls._build_command_detail_text(cmd, prefix, other_prefixes)
|
|
341
|
+
|
|
277
342
|
return {"html": html, "markdown": markdown, "text": text}
|
|
278
|
-
|
|
343
|
+
|
|
279
344
|
@classmethod
|
|
280
|
-
def _build_command_detail_html(
|
|
345
|
+
def _build_command_detail_html(
|
|
346
|
+
cls, cmd: Dict, prefix: str, other_prefixes: Optional[list] = None
|
|
347
|
+
) -> str:
|
|
281
348
|
name = cmd["name"]
|
|
282
349
|
info = cmd["info"]
|
|
283
|
-
|
|
350
|
+
|
|
284
351
|
html_parts = [
|
|
285
352
|
f"""<div style="padding: 12px; border-radius: 8px;">
|
|
286
353
|
<div style="color: {cls.PRIMARY_COLOR}; font-size: 16px; font-weight: bold; margin-bottom: 12px;">
|
|
287
354
|
命令详情: {prefix}{name}
|
|
288
355
|
</div>"""
|
|
289
356
|
]
|
|
290
|
-
|
|
357
|
+
|
|
291
358
|
# 描述
|
|
292
359
|
html_parts.append(f"""
|
|
293
360
|
<div style="margin-bottom: 12px; border: 1px solid #e0e0e0; padding: 12px; border-radius: 6px;">
|
|
@@ -295,17 +362,17 @@ class HelpTemplates:
|
|
|
295
362
|
<strong style="font-size: 14px;">描述:</strong>
|
|
296
363
|
</div>
|
|
297
364
|
<div style="font-size: 13px;">
|
|
298
|
-
{info.get(
|
|
365
|
+
{info.get("help", "暂无描述")}
|
|
299
366
|
</div>
|
|
300
367
|
</div>""")
|
|
301
|
-
|
|
368
|
+
|
|
302
369
|
# 别名 - 从全局 command.aliases 获取
|
|
303
|
-
main_name = info.get(
|
|
370
|
+
main_name = info.get("main_name", name)
|
|
304
371
|
aliases = []
|
|
305
372
|
for alias, mapped_name in command.aliases.items():
|
|
306
373
|
if mapped_name == main_name and alias != main_name:
|
|
307
374
|
aliases.append(alias)
|
|
308
|
-
|
|
375
|
+
|
|
309
376
|
if aliases:
|
|
310
377
|
aliases_text = ", ".join(f"{prefix}{a}" for a in aliases)
|
|
311
378
|
html_parts.append(f"""
|
|
@@ -317,7 +384,7 @@ class HelpTemplates:
|
|
|
317
384
|
{aliases_text}
|
|
318
385
|
</div>
|
|
319
386
|
</div>""")
|
|
320
|
-
|
|
387
|
+
|
|
321
388
|
# 用法
|
|
322
389
|
if info.get("usage"):
|
|
323
390
|
html_parts.append(f"""
|
|
@@ -326,10 +393,10 @@ class HelpTemplates:
|
|
|
326
393
|
<strong>用法:</strong>
|
|
327
394
|
</div>
|
|
328
395
|
<div style="font-size: 13px; font-family: monospace; background: rgba(0, 0, 0, 0.03); padding: 6px; border-radius: 4px;">
|
|
329
|
-
{info[
|
|
396
|
+
{info["usage"].replace("/", prefix)}
|
|
330
397
|
</div>
|
|
331
398
|
</div>""")
|
|
332
|
-
|
|
399
|
+
|
|
333
400
|
# 权限
|
|
334
401
|
if info.get("permission"):
|
|
335
402
|
html_parts.append(f"""
|
|
@@ -341,7 +408,7 @@ class HelpTemplates:
|
|
|
341
408
|
需要特殊权限
|
|
342
409
|
</div>
|
|
343
410
|
</div>""")
|
|
344
|
-
|
|
411
|
+
|
|
345
412
|
# 分组
|
|
346
413
|
if info.get("group"):
|
|
347
414
|
group_name = cls._get_group_name(info["group"])
|
|
@@ -354,97 +421,111 @@ class HelpTemplates:
|
|
|
354
421
|
{group_name}
|
|
355
422
|
</div>
|
|
356
423
|
</div>""")
|
|
357
|
-
|
|
424
|
+
|
|
425
|
+
if other_prefixes:
|
|
426
|
+
html_parts.append(f"""
|
|
427
|
+
{cls._prefix_note_html(other_prefixes)}""")
|
|
428
|
+
|
|
358
429
|
html_parts.append("</div>")
|
|
359
|
-
|
|
430
|
+
|
|
360
431
|
return "\n".join(html_parts)
|
|
361
|
-
|
|
432
|
+
|
|
362
433
|
@classmethod
|
|
363
|
-
def _build_command_detail_markdown(
|
|
434
|
+
def _build_command_detail_markdown(
|
|
435
|
+
cls, cmd: Dict, prefix: str, other_prefixes: Optional[list] = None
|
|
436
|
+
) -> str:
|
|
364
437
|
name = cmd["name"]
|
|
365
438
|
info = cmd["info"]
|
|
366
|
-
|
|
439
|
+
|
|
367
440
|
lines = [
|
|
368
441
|
f"**命令详情:** `{prefix}{name}`",
|
|
369
442
|
"",
|
|
370
443
|
f"**描述:** {info.get('help', '暂无描述')}",
|
|
371
|
-
""
|
|
444
|
+
"",
|
|
372
445
|
]
|
|
373
|
-
|
|
446
|
+
|
|
374
447
|
# 别名 - 从全局 command.aliases 获取
|
|
375
|
-
main_name = info.get(
|
|
448
|
+
main_name = info.get("main_name", name)
|
|
376
449
|
aliases = []
|
|
377
450
|
for alias, mapped_name in command.aliases.items():
|
|
378
451
|
if mapped_name == main_name and alias != main_name:
|
|
379
452
|
aliases.append(alias)
|
|
380
|
-
|
|
453
|
+
|
|
381
454
|
if aliases:
|
|
382
455
|
aliases_text = ", ".join(f"`{prefix}{a}`" for a in aliases)
|
|
383
456
|
lines.append(f"**别名:** {aliases_text}")
|
|
384
457
|
lines.append("")
|
|
385
|
-
|
|
458
|
+
|
|
386
459
|
# 用法
|
|
387
460
|
if info.get("usage"):
|
|
388
461
|
lines.append(f"**用法:** `{info['usage'].replace('/', prefix)}`")
|
|
389
462
|
lines.append("")
|
|
390
|
-
|
|
463
|
+
|
|
391
464
|
# 权限
|
|
392
465
|
if info.get("permission"):
|
|
393
466
|
lines.append("**权限:** 需要特殊权限")
|
|
394
467
|
lines.append("")
|
|
395
|
-
|
|
468
|
+
|
|
396
469
|
# 分组
|
|
397
470
|
if info.get("group"):
|
|
398
471
|
group_name = cls._get_group_name(info["group"])
|
|
399
472
|
lines.append(f"**分组:** {group_name}")
|
|
400
473
|
lines.append("")
|
|
401
|
-
|
|
474
|
+
if other_prefixes:
|
|
475
|
+
lines.append(f"其他触发前缀: {'、'.join(other_prefixes)}")
|
|
476
|
+
lines.append("")
|
|
477
|
+
|
|
402
478
|
return "\n".join(lines)
|
|
403
|
-
|
|
479
|
+
|
|
404
480
|
@classmethod
|
|
405
|
-
def _build_command_detail_text(
|
|
481
|
+
def _build_command_detail_text(
|
|
482
|
+
cls, cmd: Dict, prefix: str, other_prefixes: Optional[list] = None
|
|
483
|
+
) -> str:
|
|
406
484
|
name = cmd["name"]
|
|
407
485
|
info = cmd["info"]
|
|
408
|
-
|
|
486
|
+
|
|
409
487
|
lines = [
|
|
410
488
|
f"命令详情: {prefix}{name}",
|
|
411
489
|
"----------",
|
|
412
490
|
f"描述: {info.get('help', '暂无描述')}",
|
|
413
|
-
""
|
|
491
|
+
"",
|
|
414
492
|
]
|
|
415
|
-
|
|
493
|
+
|
|
416
494
|
# 别名 - 从全局 command.aliases 获取
|
|
417
|
-
main_name = info.get(
|
|
495
|
+
main_name = info.get("main_name", name)
|
|
418
496
|
aliases = []
|
|
419
497
|
for alias, mapped_name in command.aliases.items():
|
|
420
498
|
if mapped_name == main_name and alias != main_name:
|
|
421
499
|
aliases.append(alias)
|
|
422
|
-
|
|
500
|
+
|
|
423
501
|
if aliases:
|
|
424
502
|
aliases_text = ", ".join(f"{prefix}{a}" for a in aliases)
|
|
425
503
|
lines.append(f"别名: {aliases_text}")
|
|
426
504
|
lines.append("")
|
|
427
|
-
|
|
505
|
+
|
|
428
506
|
# 用法
|
|
429
507
|
if info.get("usage"):
|
|
430
508
|
lines.append(f"用法: {info['usage'].replace('/', prefix)}")
|
|
431
509
|
lines.append("")
|
|
432
|
-
|
|
510
|
+
|
|
433
511
|
# 权限
|
|
434
512
|
if info.get("permission"):
|
|
435
513
|
lines.append("权限: 需要特殊权限")
|
|
436
514
|
lines.append("")
|
|
437
|
-
|
|
515
|
+
|
|
438
516
|
# 分组
|
|
439
517
|
if info.get("group"):
|
|
440
518
|
group_name = cls._get_group_name(info["group"])
|
|
441
519
|
lines.append(f"分组: {group_name}")
|
|
442
520
|
lines.append("")
|
|
443
|
-
|
|
521
|
+
if other_prefixes:
|
|
522
|
+
lines.append(f"其他触发前缀: {'、'.join(other_prefixes)}")
|
|
523
|
+
lines.append("")
|
|
524
|
+
|
|
444
525
|
return "\n".join(lines)
|
|
445
|
-
|
|
526
|
+
|
|
446
527
|
# ==================== 错误消息模板 ====================
|
|
447
|
-
|
|
528
|
+
|
|
448
529
|
@classmethod
|
|
449
530
|
def build_error(cls, title: str, message: str) -> Dict[str, str]:
|
|
450
531
|
html = f"""
|
|
@@ -452,9 +533,9 @@ class HelpTemplates:
|
|
|
452
533
|
<div style="color: {cls.ERROR_COLOR}; font-size: 14px; font-weight: bold; margin-bottom: 8px;">{title}</div>
|
|
453
534
|
<div style="font-size: 13px;">{message}</div>
|
|
454
535
|
</div>"""
|
|
455
|
-
|
|
536
|
+
|
|
456
537
|
markdown = f"**{title}**\n\n{message}"
|
|
457
|
-
|
|
538
|
+
|
|
458
539
|
text = f"{title}\n\n{message}"
|
|
459
|
-
|
|
460
|
-
return {"html": html, "markdown": markdown, "text": text}
|
|
540
|
+
|
|
541
|
+
return {"html": html, "markdown": markdown, "text": text}
|
|
File without changes
|
{erispulse_helpmodule-2.1.1 → erispulse_helpmodule-2.1.2}/ErisPulse_HelpModule.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|