Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 关于统一元数据声明中usage的细化 #1065

Closed
hamo-reid opened this issue Jun 27, 2022 · 4 comments
Closed

Feature: 关于统一元数据声明中usage的细化 #1065

hamo-reid opened this issue Jun 27, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@hamo-reid
Copy link
Contributor

目前PluginMetadata中的usage为string类型,但是对于功能很多的插件,若usage没有标准化结构可能无法准确阐述插件功能,也会对菜单等插件开发造成困难

因此希望对usage的结构进行标准化,一下是我设想的两种usage结构

方案1: 用列表嵌套字典来实现,功能数据用字典中键值对储存

__plugin_meta__ = PluginMetadata(
    name="测试插件",
    description="测试插件元信息",
    usage=[
        {
            'fanc': '测试',
            'trigger_method': 'on_cmd',
            'trigger_conditon': '/test',
            'brief_des': '测试命令',
            'detail_des': '用于测试的命令,没有什么用'
        },
        {
            'fanc': '服务器状态反馈''trigger_method': '定时触发',
            'trigger_conditon': '每日0时',
            'brief_des': '定时发送服务器状态',
            'detail_des': '定时向superuser发送服务器状态\n'
                          '包含以下信息:\n'
                          '系统时间、内存、CPU、储存空间'
        },
    ],
    extra={"author": "NoneBot"},
)

方案2: 用类似与PluginMetadata的方法储存功能数据,存放于列表中

@dataclass
class FuncMetadata:
    fanc: str  # 功能名称
    trigger_method: str  #  触发方式
    trigger_condition: str  # 触发条件
    brief_des: str  # 简短描述
    detail_des: str  # 详细描述(用法,注意事项等等)


__plugin_meta__ = PluginMetadata(
    name="测试插件",
    description="测试插件元信息",
    usage=[
        FuncMetadata(
            fanc='测试'trigger_method='on_cmd',
            trigger_conditon='/test',
            brief_des='测试命令',
            detail_des='用于测试的命令,没有什么用'
        ),
        FuncMetadata(
            fanc='服务器状态反馈'trigger_method='定时触发',
            trigger_conditon='每日0时',
            brief_des='定时发送服务器状态',
            detail_des='定时向superuser发送服务器状态\n'
                       '包含以下信息:\n'
                       '系统时间、内存、CPU、储存空间'
        ),
    ],
    extra={"author": "NoneBot"},
)

这样可以实现更具针对性的查找某一插件的某一功能

@hamo-reid hamo-reid added the enhancement New feature or request label Jun 27, 2022
@Well2333
Copy link
Contributor

#1015
#1046

@yanyongyu
Copy link
Member

插件元数据希望提供最基础的插件使用方法,str具有较高的通用性,如果你需要更复杂的配置,请自行在extra里编写

@Well2333
Copy link
Contributor

目前官方仍希望对此功能保留更多的自由发挥的空间,因此不会进行强制规定。
可以尝试在自己的help插件中声明接入此插件所需的内容,并置入extra中,并等待其他插件作者的主动适配。

@hamo-reid
Copy link
Contributor Author

好的,了解了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants