ErisPulse-HelpModule 2.1.1__tar.gz → 2.1.3__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.
@@ -38,10 +38,21 @@ class HelpModule(BaseModule):
38
38
  return default_config
39
39
  return module_config
40
40
 
41
+ def _get_all_prefixes(self) -> list:
42
+ """获取所有命令前缀列表(优先读框架维护的 command.prefix,旧版回退手读配置)"""
43
+ prefix = getattr(command, "prefix", None)
44
+ if prefix is None:
45
+ event_config = config.getConfig("ErisPulse.event", {}) or {}
46
+ command_config = event_config.get("command", {}) or {}
47
+ prefix = command_config.get("prefix", "/")
48
+ if isinstance(prefix, list):
49
+ return [str(p) for p in prefix] if prefix else ["/"]
50
+ return [str(prefix)] if prefix else ["/"]
51
+
41
52
  def _get_command_prefix(self) -> str:
42
- event_config = config.getConfig("ErisPulse.event", {})
43
- command_config = event_config.get("command", {})
44
- return command_config.get("prefix", "/")
53
+ """获取主显示前缀(第一个)"""
54
+ prefixes = self._get_all_prefixes()
55
+ return prefixes[0] if prefixes else "/"
45
56
 
46
57
  def _register_commands(self):
47
58
  self.help_command_func = self._create_help_command()
@@ -62,21 +73,47 @@ class HelpModule(BaseModule):
62
73
 
63
74
  return help_command
64
75
 
65
- def _build_command_list(self) -> List[Dict]:
76
+ # ==================== 会话感知查询(旧版框架自动回退) ====================
77
+
78
+ @staticmethod
79
+ def _query_commands(event) -> Dict:
80
+ """获取命令注册表;新版框架按作用域过滤当前会话不可用模块的命令"""
81
+ try:
82
+ return command.get_commands(event=event)
83
+ except TypeError:
84
+ return command.get_commands()
85
+
86
+ @staticmethod
87
+ def _query_visible_commands(event) -> Dict:
88
+ """获取可见命令;新版框架按作用域过滤当前会话不可用模块的命令"""
89
+ try:
90
+ return command.get_visible_commands(event=event)
91
+ except TypeError:
92
+ return command.get_visible_commands()
93
+
94
+ @staticmethod
95
+ def _query_command(name: str, event) -> Optional[Dict]:
96
+ """获取生效命令信息;新版框架在会话不可用时返回 None"""
97
+ try:
98
+ return command.get_command(name, event=event)
99
+ except TypeError:
100
+ return command.get_command(name)
101
+
102
+ def _build_command_list(self, event) -> List[Dict]:
66
103
  self.command_list = []
67
104
  module_config = self._get_config()
68
105
  show_hidden = module_config.get("show_hidden_commands", False)
69
106
 
70
107
  if show_hidden:
71
- all_commands = command.get_commands()
108
+ all_commands = self._query_commands(event)
72
109
  for cmd_name in all_commands:
73
- cmd_info = command.get_command(cmd_name)
110
+ cmd_info = self._query_command(cmd_name, event)
74
111
  if cmd_info and cmd_name == cmd_info.get("main_name"):
75
112
  self.command_list.append({"name": cmd_name, "info": cmd_info})
76
113
  else:
77
- visible_commands = command.get_visible_commands()
114
+ visible_commands = self._query_visible_commands(event)
78
115
  for cmd_name in visible_commands:
79
- cmd_info = command.get_command(cmd_name)
116
+ cmd_info = self._query_command(cmd_name, event)
80
117
  if cmd_info and cmd_name == cmd_info.get("main_name"):
81
118
  self.command_list.append({"name": cmd_name, "info": cmd_info})
82
119
 
@@ -96,9 +133,11 @@ class HelpModule(BaseModule):
96
133
  platform = event.get_platform()
97
134
  args = event.get_command_args()
98
135
 
99
- commands = self._build_command_list()
136
+ commands = self._build_command_list(event)
100
137
  module_config = self._get_config()
101
138
 
139
+ prefixes = self._get_all_prefixes()
140
+
102
141
  if args:
103
142
  # 显示命令详情
104
143
  try:
@@ -106,7 +145,9 @@ class HelpModule(BaseModule):
106
145
  if index in self.command_map:
107
146
  # 使用模板构建命令详情
108
147
  templates = HelpTemplates.build_command_detail(
109
- self.command_map[index], self._get_command_prefix()
148
+ self.command_map[index],
149
+ self._get_command_prefix(),
150
+ prefixes,
110
151
  )
111
152
  else:
112
153
  # 使用错误模板
@@ -124,6 +165,7 @@ class HelpModule(BaseModule):
124
165
  self.command_map,
125
166
  self._get_command_prefix(),
126
167
  module_config.get("group_commands", True),
168
+ prefixes,
127
169
  )
128
170
 
129
171
  # 根据平台能力选择最佳格式,通过 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(cls, commands: List[Dict], command_map: Dict[int, Dict],
34
- prefix: str, group_commands: bool = True) -> Dict[str, str]:
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(commands, command_map, prefix, group_commands)
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(commands, command_map, prefix, group_commands)
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(commands, command_map, prefix, group_commands)
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(cls, commands: List[Dict], command_map: Dict[int, Dict],
48
- prefix: str, group_commands: bool) -> str:
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(cls, commands: List[Dict], command_map: Dict[int, Dict],
117
- prefix: str, group_commands: bool) -> str:
118
- lines = [
119
- "**命令帮助**",
120
- "",
121
- f"使用 `{prefix}help <序号>` 查看命令详情",
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(cls, commands: List[Dict], command_map: Dict[int, Dict],
166
- prefix: str, group_commands: bool) -> str:
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('help', '暂无描述')}</span>
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('main_name', name)
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(f"<code style='font-size: 11px;'>{prefix}{a}</code>" for a in aliases)
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['usage'].replace('/', prefix)}</span>
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(cls, cmd: Dict, prefix: str) -> Dict[str, str]:
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(cls, cmd: Dict, prefix: str) -> str:
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('help', '暂无描述')}
365
+ {info.get("help", "暂无描述")}
299
366
  </div>
300
367
  </div>""")
301
-
368
+
302
369
  # 别名 - 从全局 command.aliases 获取
303
- main_name = info.get('main_name', name)
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['usage'].replace('/', prefix)}
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(cls, cmd: Dict, prefix: str) -> str:
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('main_name', name)
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(cls, cmd: Dict, prefix: str) -> str:
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('main_name', name)
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}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ErisPulse-HelpModule
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明
5
5
  Author-email: wsu2059q <wsu2059@qq.com>
6
6
  License-Expression: MIT
@@ -13,6 +13,9 @@ Dynamic: license-file
13
13
  # ErisPulse-HelpModule
14
14
  ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明
15
15
 
16
+ > **2.7.0+ 用户推荐使用 [ErisPulse-HelpNext](https://pypi.org/project/ErisPulse-HelpNext/)**(Takumi 图片渲染 / 昼夜主题 / 完整 i18n)。
17
+ > 本模块(HelpModule)继续保留,优先保持**向后兼容性**,适合无法使用 Takumi 图片渲染或停留在旧版本的环境。
18
+
16
19
  ## 功能特性
17
20
  提供 Event 子模块中 command 模块中统一的命令帮助功能
18
21
  - 自动收集并显示所有已注册的命令
@@ -20,6 +23,7 @@ ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查
20
23
  - 支持命令分组显示
21
24
  - 可配置是否显示隐藏命令
22
25
  - 支持命令别名显示
26
+ - 会话感知(ErisPulse 2.8.0+):被作用域禁用的模块,其命令不在当前会话的帮助中列出;旧版框架自动回退为全量列表,行为不变
23
27
 
24
28
  ## 使用方法
25
29
 
@@ -55,3 +59,14 @@ group_commands = true # 是否按组显示命令
55
59
  ## 依赖
56
60
 
57
61
  - ErisPulse SDK 2.2.0+
62
+
63
+ ## 升级到 Next
64
+
65
+ 如果你在使用 ErisPulse 2.7.0+ 且需要图片化帮助(Apple 风格卡片、昼夜主题、多语言),请安装 HelpNext:
66
+
67
+ ```bash
68
+ epsdk install HelpNext
69
+ epsdk uninstall HelpModule
70
+ ```
71
+
72
+ > 注意:HelpModule 与 HelpNext 都注册 `/help` 命令,请只启用其中一个。
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ErisPulse-HelpModule
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明
5
5
  Author-email: wsu2059q <wsu2059@qq.com>
6
6
  License-Expression: MIT
@@ -13,6 +13,9 @@ Dynamic: license-file
13
13
  # ErisPulse-HelpModule
14
14
  ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明
15
15
 
16
+ > **2.7.0+ 用户推荐使用 [ErisPulse-HelpNext](https://pypi.org/project/ErisPulse-HelpNext/)**(Takumi 图片渲染 / 昼夜主题 / 完整 i18n)。
17
+ > 本模块(HelpModule)继续保留,优先保持**向后兼容性**,适合无法使用 Takumi 图片渲染或停留在旧版本的环境。
18
+
16
19
  ## 功能特性
17
20
  提供 Event 子模块中 command 模块中统一的命令帮助功能
18
21
  - 自动收集并显示所有已注册的命令
@@ -20,6 +23,7 @@ ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查
20
23
  - 支持命令分组显示
21
24
  - 可配置是否显示隐藏命令
22
25
  - 支持命令别名显示
26
+ - 会话感知(ErisPulse 2.8.0+):被作用域禁用的模块,其命令不在当前会话的帮助中列出;旧版框架自动回退为全量列表,行为不变
23
27
 
24
28
  ## 使用方法
25
29
 
@@ -55,3 +59,14 @@ group_commands = true # 是否按组显示命令
55
59
  ## 依赖
56
60
 
57
61
  - ErisPulse SDK 2.2.0+
62
+
63
+ ## 升级到 Next
64
+
65
+ 如果你在使用 ErisPulse 2.7.0+ 且需要图片化帮助(Apple 风格卡片、昼夜主题、多语言),请安装 HelpNext:
66
+
67
+ ```bash
68
+ epsdk install HelpNext
69
+ epsdk uninstall HelpModule
70
+ ```
71
+
72
+ > 注意:HelpModule 与 HelpNext 都注册 `/help` 命令,请只启用其中一个。
@@ -1,6 +1,9 @@
1
1
  # ErisPulse-HelpModule
2
2
  ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明
3
3
 
4
+ > **2.7.0+ 用户推荐使用 [ErisPulse-HelpNext](https://pypi.org/project/ErisPulse-HelpNext/)**(Takumi 图片渲染 / 昼夜主题 / 完整 i18n)。
5
+ > 本模块(HelpModule)继续保留,优先保持**向后兼容性**,适合无法使用 Takumi 图片渲染或停留在旧版本的环境。
6
+
4
7
  ## 功能特性
5
8
  提供 Event 子模块中 command 模块中统一的命令帮助功能
6
9
  - 自动收集并显示所有已注册的命令
@@ -8,6 +11,7 @@ ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查
8
11
  - 支持命令分组显示
9
12
  - 可配置是否显示隐藏命令
10
13
  - 支持命令别名显示
14
+ - 会话感知(ErisPulse 2.8.0+):被作用域禁用的模块,其命令不在当前会话的帮助中列出;旧版框架自动回退为全量列表,行为不变
11
15
 
12
16
  ## 使用方法
13
17
 
@@ -43,3 +47,14 @@ group_commands = true # 是否按组显示命令
43
47
  ## 依赖
44
48
 
45
49
  - ErisPulse SDK 2.2.0+
50
+
51
+ ## 升级到 Next
52
+
53
+ 如果你在使用 ErisPulse 2.7.0+ 且需要图片化帮助(Apple 风格卡片、昼夜主题、多语言),请安装 HelpNext:
54
+
55
+ ```bash
56
+ epsdk install HelpNext
57
+ epsdk uninstall HelpModule
58
+ ```
59
+
60
+ > 注意:HelpModule 与 HelpNext 都注册 `/help` 命令,请只启用其中一个。
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ErisPulse-HelpModule"
3
- version = "2.1.1"
3
+ version = "2.1.3"
4
4
  description = "ErisPulse 帮助命令模块,提供自动化的命令帮助系统,支持查看所有可用命令及其用法说明"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"