mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
其他适配了beta4
元数据的插件也会显示在paimon_help
帮助面板图片
This commit is contained in:
parent
183fb1970c
commit
ed0e759d8b
@ -120,14 +120,21 @@ async def get_all_plugin(event: MessageEvent) -> dict:
|
|||||||
if plugin_type not in help_info:
|
if plugin_type not in help_info:
|
||||||
help_info[plugin_type] = []
|
help_info[plugin_type] = []
|
||||||
matchers = plugin.matcher
|
matchers = plugin.matcher
|
||||||
|
matcher_flag = False
|
||||||
for matcher in matchers:
|
for matcher in matchers:
|
||||||
try:
|
try:
|
||||||
matchers_info = matcher.__paimon_help__
|
matchers_info = matcher.__paimon_help__
|
||||||
if 'priority' not in matchers_info:
|
if 'priority' not in matchers_info:
|
||||||
matchers_info['priority'] = 99
|
matchers_info['priority'] = 99
|
||||||
help_info[plugin_type].append(matchers_info)
|
help_info[plugin_type].append(matchers_info)
|
||||||
|
matcher_flag = True
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
if not matcher_flag:
|
||||||
|
try:
|
||||||
|
help_info[plugin_type].append({'usage': plugin.metadata.name, 'introduce': plugin.metadata.description, 'priority': 99})
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
help_info = {k: v for k, v in help_info.items() if v}
|
help_info = {k: v for k, v in help_info.items() if v}
|
||||||
if not help_info:
|
if not help_info:
|
||||||
await help_.finish('当前没有已加载的插件哦')
|
await help_.finish('当前没有已加载的插件哦')
|
||||||
|
@ -5,11 +5,21 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
def get_short_name(name: str):
|
def get_short_name(name: str):
|
||||||
|
"""
|
||||||
|
获取角色或武器的短名(2个字)
|
||||||
|
:param name: 角色或武器名
|
||||||
|
:return: 短名字符串
|
||||||
|
"""
|
||||||
short_name = load_json(path=os.path.join(os.path.dirname(__file__), 'short_name.json'))
|
short_name = load_json(path=os.path.join(os.path.dirname(__file__), 'short_name.json'))
|
||||||
return name if name not in short_name.keys() else short_name[name]
|
return name if name not in short_name.keys() else short_name[name]
|
||||||
|
|
||||||
|
|
||||||
def get_id_by_name(name: str):
|
def get_id_by_name(name: str):
|
||||||
|
"""
|
||||||
|
根据角色名字获取角色的id
|
||||||
|
:param name: 角色名
|
||||||
|
:return: id字符串
|
||||||
|
"""
|
||||||
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
||||||
name_list = alias_file['roles']
|
name_list = alias_file['roles']
|
||||||
for role_id, alias in name_list.items():
|
for role_id, alias in name_list.items():
|
||||||
@ -18,6 +28,11 @@ def get_id_by_name(name: str):
|
|||||||
|
|
||||||
|
|
||||||
def get_name_by_id(role_id: str):
|
def get_name_by_id(role_id: str):
|
||||||
|
"""
|
||||||
|
根据角色id获取角色名
|
||||||
|
:param role_id: 角色id
|
||||||
|
:return: 角色名字符串
|
||||||
|
"""
|
||||||
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
||||||
name_list = alias_file['roles']
|
name_list = alias_file['roles']
|
||||||
if role_id in name_list:
|
if role_id in name_list:
|
||||||
@ -27,6 +42,13 @@ def get_name_by_id(role_id: str):
|
|||||||
|
|
||||||
|
|
||||||
def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False) -> Union[str, list, dict]:
|
def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False) -> Union[str, list, dict]:
|
||||||
|
"""
|
||||||
|
根据字符串消息,获取与之相似或匹配的角色、武器、原魔名
|
||||||
|
:param msg: 消息
|
||||||
|
:param type: 匹配类型,有roles、weapons、monsters
|
||||||
|
:param single_to_dict: 是否将角色单结果也转换成{角色:id}字典
|
||||||
|
:return: 匹配的字符串、列表或字典
|
||||||
|
"""
|
||||||
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
alias_file = load_json(path=os.path.join(os.path.dirname(__file__), 'alias.json'))
|
||||||
alias_list = alias_file[type]
|
alias_list = alias_file[type]
|
||||||
if msg in ['风主', '岩主', '雷主']:
|
if msg in ['风主', '岩主', '雷主']:
|
||||||
|
Loading…
Reference in New Issue
Block a user