nonebot-plugin-picmenu-next 0.1.0.dev1__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.
Files changed (17) hide show
  1. nonebot_plugin_picmenu_next-0.1.0.dev1/LICENSE +21 -0
  2. nonebot_plugin_picmenu_next-0.1.0.dev1/PKG-INFO +175 -0
  3. nonebot_plugin_picmenu_next-0.1.0.dev1/README.md +159 -0
  4. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/__init__.py +37 -0
  5. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/__main__.py +183 -0
  6. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/config.py +13 -0
  7. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/data_source.py +341 -0
  8. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/__init__.py +77 -0
  9. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/__init__.py +147 -0
  10. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/base.html.jinja +28 -0
  11. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/css/base.css +137 -0
  12. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/css/dark.css +10 -0
  13. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/css/detail.css +16 -0
  14. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/css/index.css +9 -0
  15. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/detail.html.jinja +68 -0
  16. nonebot_plugin_picmenu_next-0.1.0.dev1/nonebot_plugin_picmenu_next/templates/default/res/index.html.jinja +21 -0
  17. nonebot_plugin_picmenu_next-0.1.0.dev1/pyproject.toml +40 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 LgCookie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: nonebot-plugin-picmenu-next
3
+ Version: 0.1.0.dev1
4
+ Summary: Template plugin project
5
+ Author-Email: LgCookie <lgc2333@126.com>
6
+ License: MIT
7
+ Project-URL: homepage, https://github.com/lgc-NB2Dev/nonebot-plugin-picmenu-next
8
+ Requires-Python: <4.0,>=3.9
9
+ Requires-Dist: nonebot2>=2.4.1
10
+ Requires-Dist: nonebot-plugin-alconna>=0.54.2
11
+ Requires-Dist: cookit[jinja,loguru,nonebot-alconna,nonebot-localstore,pw,pyd]>=0.11.2
12
+ Requires-Dist: pypinyin>=0.54.0
13
+ Requires-Dist: jieba>=0.42.1
14
+ Requires-Dist: thefuzz>=0.22.1
15
+ Description-Content-Type: text/markdown
16
+
17
+ <!-- markdownlint-disable MD031 MD033 MD036 MD041 -->
18
+
19
+ <div align="center">
20
+
21
+ <a href="https://v2.nonebot.dev/store">
22
+ <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
23
+ </a>
24
+
25
+ <p>
26
+ <img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
27
+ </p>
28
+
29
+ # NoneBot-Plugin-PicMenu-Next
30
+
31
+ _✨ NoneBot 插件简单描述 ✨_
32
+
33
+ <img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
34
+ <a href="https://pdm.fming.dev">
35
+ <img src="https://img.shields.io/badge/pdm-managed-blueviolet" alt="pdm-managed">
36
+ </a>
37
+ <a href="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb">
38
+ <img src="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb.svg" alt="wakatime">
39
+ </a>
40
+
41
+ <br />
42
+
43
+ <a href="https://pydantic.dev">
44
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/pyd-v1-or-v2.json" alt="Pydantic Version 1 Or 2" >
45
+ </a>
46
+ <a href="./LICENSE">
47
+ <img src="https://img.shields.io/github/license/lgc-NB2Dev/nonebot-plugin-picmenu-next.svg" alt="license">
48
+ </a>
49
+ <a href="https://pypi.python.org/pypi/nonebot-plugin-picmenu-next">
50
+ <img src="https://img.shields.io/pypi/v/nonebot-plugin-picmenu-next.svg" alt="pypi">
51
+ </a>
52
+ <a href="https://pypi.python.org/pypi/nonebot-plugin-picmenu-next">
53
+ <img src="https://img.shields.io/pypi/dm/nonebot-plugin-picmenu-next" alt="pypi download">
54
+ </a>
55
+
56
+ <br />
57
+
58
+ <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-picmenu-next:nonebot_plugin_picmenu_next">
59
+ <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-picmenu-next" alt="NoneBot Registry">
60
+ </a>
61
+ <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-picmenu-next:nonebot_plugin_picmenu_next">
62
+ <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-picmenu-next" alt="Supported Adapters">
63
+ </a>
64
+
65
+ </div>
66
+
67
+ ## 📖 介绍
68
+
69
+ 这里是插件的详细介绍部分
70
+
71
+ ## 💿 安装
72
+
73
+ 以下提到的方法 任选**其一** 即可
74
+
75
+ <details open>
76
+ <summary>[推荐] 使用 nb-cli 安装</summary>
77
+ 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
78
+
79
+ ```bash
80
+ nb plugin install nonebot-plugin-picmenu-next
81
+ ```
82
+
83
+ </details>
84
+
85
+ <details>
86
+ <summary>使用包管理器安装</summary>
87
+ 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
88
+
89
+ <details>
90
+ <summary>pip</summary>
91
+
92
+ ```bash
93
+ pip install nonebot-plugin-picmenu-next
94
+ ```
95
+
96
+ </details>
97
+ <details>
98
+ <summary>pdm</summary>
99
+
100
+ ```bash
101
+ pdm add nonebot-plugin-picmenu-next
102
+ ```
103
+
104
+ </details>
105
+ <details>
106
+ <summary>poetry</summary>
107
+
108
+ ```bash
109
+ poetry add nonebot-plugin-picmenu-next
110
+ ```
111
+
112
+ </details>
113
+ <details>
114
+ <summary>conda</summary>
115
+
116
+ ```bash
117
+ conda install nonebot-plugin-picmenu-next
118
+ ```
119
+
120
+ </details>
121
+
122
+ 打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分的 `plugins` 项里追加写入
123
+
124
+ ```toml
125
+ [tool.nonebot]
126
+ plugins = [
127
+ # ...
128
+ "nonebot_plugin_picmenu_next"
129
+ ]
130
+ ```
131
+
132
+ </details>
133
+
134
+ ## ⚙️ 配置
135
+
136
+ 在 nonebot2 项目的 `.env` 文件中添加下表中的必填配置
137
+
138
+ | 配置项 | 必填 | 默认值 | 说明 |
139
+ | :------: | :--: | :----: | :------: |
140
+ | 配置项 1 | 是 | 无 | 配置说明 |
141
+ | 配置项 2 | 否 | 无 | 配置说明 |
142
+
143
+ ## 🎉 使用
144
+
145
+ ### 指令表
146
+
147
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
148
+ | :----: | :--: | :---: | :--: | :------: |
149
+ | 指令 1 | 主人 | 否 | 私聊 | 指令说明 |
150
+ | 指令 2 | 群员 | 是 | 群聊 | 指令说明 |
151
+
152
+ ### 效果图
153
+
154
+ 如果有效果图的话
155
+
156
+ ## 📞 联系
157
+
158
+ QQ:3076823485
159
+ Telegram:[@lgc2333](https://t.me/lgc2333)
160
+ 吹水群:[1105946125](https://jq.qq.com/?_wv=1027&k=Z3n1MpEp)
161
+ 邮箱:<lgc2333@126.com>
162
+
163
+ ## 💡 鸣谢
164
+
165
+ 如果有要鸣谢的人的话
166
+
167
+ ## 💰 赞助
168
+
169
+ **[赞助我](https://blog.lgc2333.top/donate)**
170
+
171
+ 感谢大家的赞助!你们的赞助将是我继续创作的动力!
172
+
173
+ ## 📝 更新日志
174
+
175
+ 芝士刚刚发布的插件,还没有更新日志的说 qwq~
@@ -0,0 +1,159 @@
1
+ <!-- markdownlint-disable MD031 MD033 MD036 MD041 -->
2
+
3
+ <div align="center">
4
+
5
+ <a href="https://v2.nonebot.dev/store">
6
+ <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
7
+ </a>
8
+
9
+ <p>
10
+ <img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
11
+ </p>
12
+
13
+ # NoneBot-Plugin-PicMenu-Next
14
+
15
+ _✨ NoneBot 插件简单描述 ✨_
16
+
17
+ <img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
18
+ <a href="https://pdm.fming.dev">
19
+ <img src="https://img.shields.io/badge/pdm-managed-blueviolet" alt="pdm-managed">
20
+ </a>
21
+ <a href="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb">
22
+ <img src="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb.svg" alt="wakatime">
23
+ </a>
24
+
25
+ <br />
26
+
27
+ <a href="https://pydantic.dev">
28
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/pyd-v1-or-v2.json" alt="Pydantic Version 1 Or 2" >
29
+ </a>
30
+ <a href="./LICENSE">
31
+ <img src="https://img.shields.io/github/license/lgc-NB2Dev/nonebot-plugin-picmenu-next.svg" alt="license">
32
+ </a>
33
+ <a href="https://pypi.python.org/pypi/nonebot-plugin-picmenu-next">
34
+ <img src="https://img.shields.io/pypi/v/nonebot-plugin-picmenu-next.svg" alt="pypi">
35
+ </a>
36
+ <a href="https://pypi.python.org/pypi/nonebot-plugin-picmenu-next">
37
+ <img src="https://img.shields.io/pypi/dm/nonebot-plugin-picmenu-next" alt="pypi download">
38
+ </a>
39
+
40
+ <br />
41
+
42
+ <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-picmenu-next:nonebot_plugin_picmenu_next">
43
+ <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-picmenu-next" alt="NoneBot Registry">
44
+ </a>
45
+ <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-picmenu-next:nonebot_plugin_picmenu_next">
46
+ <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-picmenu-next" alt="Supported Adapters">
47
+ </a>
48
+
49
+ </div>
50
+
51
+ ## 📖 介绍
52
+
53
+ 这里是插件的详细介绍部分
54
+
55
+ ## 💿 安装
56
+
57
+ 以下提到的方法 任选**其一** 即可
58
+
59
+ <details open>
60
+ <summary>[推荐] 使用 nb-cli 安装</summary>
61
+ 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
62
+
63
+ ```bash
64
+ nb plugin install nonebot-plugin-picmenu-next
65
+ ```
66
+
67
+ </details>
68
+
69
+ <details>
70
+ <summary>使用包管理器安装</summary>
71
+ 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
72
+
73
+ <details>
74
+ <summary>pip</summary>
75
+
76
+ ```bash
77
+ pip install nonebot-plugin-picmenu-next
78
+ ```
79
+
80
+ </details>
81
+ <details>
82
+ <summary>pdm</summary>
83
+
84
+ ```bash
85
+ pdm add nonebot-plugin-picmenu-next
86
+ ```
87
+
88
+ </details>
89
+ <details>
90
+ <summary>poetry</summary>
91
+
92
+ ```bash
93
+ poetry add nonebot-plugin-picmenu-next
94
+ ```
95
+
96
+ </details>
97
+ <details>
98
+ <summary>conda</summary>
99
+
100
+ ```bash
101
+ conda install nonebot-plugin-picmenu-next
102
+ ```
103
+
104
+ </details>
105
+
106
+ 打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分的 `plugins` 项里追加写入
107
+
108
+ ```toml
109
+ [tool.nonebot]
110
+ plugins = [
111
+ # ...
112
+ "nonebot_plugin_picmenu_next"
113
+ ]
114
+ ```
115
+
116
+ </details>
117
+
118
+ ## ⚙️ 配置
119
+
120
+ 在 nonebot2 项目的 `.env` 文件中添加下表中的必填配置
121
+
122
+ | 配置项 | 必填 | 默认值 | 说明 |
123
+ | :------: | :--: | :----: | :------: |
124
+ | 配置项 1 | 是 | 无 | 配置说明 |
125
+ | 配置项 2 | 否 | 无 | 配置说明 |
126
+
127
+ ## 🎉 使用
128
+
129
+ ### 指令表
130
+
131
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
132
+ | :----: | :--: | :---: | :--: | :------: |
133
+ | 指令 1 | 主人 | 否 | 私聊 | 指令说明 |
134
+ | 指令 2 | 群员 | 是 | 群聊 | 指令说明 |
135
+
136
+ ### 效果图
137
+
138
+ 如果有效果图的话
139
+
140
+ ## 📞 联系
141
+
142
+ QQ:3076823485
143
+ Telegram:[@lgc2333](https://t.me/lgc2333)
144
+ 吹水群:[1105946125](https://jq.qq.com/?_wv=1027&k=Z3n1MpEp)
145
+ 邮箱:<lgc2333@126.com>
146
+
147
+ ## 💡 鸣谢
148
+
149
+ 如果有要鸣谢的人的话
150
+
151
+ ## 💰 赞助
152
+
153
+ **[赞助我](https://blog.lgc2333.top/donate)**
154
+
155
+ 感谢大家的赞助!你们的赞助将是我继续创作的动力!
156
+
157
+ ## 📝 更新日志
158
+
159
+ 芝士刚刚发布的插件,还没有更新日志的说 qwq~
@@ -0,0 +1,37 @@
1
+ # ruff: noqa: E402
2
+
3
+ from nonebot import get_driver
4
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters, require
5
+
6
+ require("nonebot_plugin_alconna")
7
+ require("nonebot_plugin_waiter")
8
+ require("nonebot_plugin_htmlrender")
9
+
10
+ from . import __main__ as __main__
11
+ from .config import ConfigModel
12
+ from .data_source import refresh_infos
13
+ from .templates import load_builtin_templates
14
+
15
+ __version__ = "0.1.0.dev1"
16
+ __plugin_meta__ = PluginMetadata(
17
+ name="PicMenu Next",
18
+ description="新一代的图片帮助插件",
19
+ usage="发送“帮助”查看所有所有插件功能",
20
+ type="application",
21
+ homepage="https://github.com/lgc-NB2Dev/nonebot-plugin-picmenu-next",
22
+ config=ConfigModel,
23
+ supported_adapters=inherit_supported_adapters(
24
+ "nonebot_plugin_alconna",
25
+ "nonebot_plugin_waiter",
26
+ ),
27
+ extra={"License": "MIT", "Author": "LgCookie"},
28
+ )
29
+
30
+ load_builtin_templates()
31
+
32
+ driver = get_driver()
33
+
34
+
35
+ @driver.on_startup
36
+ async def _():
37
+ await refresh_infos()
@@ -0,0 +1,183 @@
1
+ from collections.abc import Sequence
2
+ from contextlib import suppress
3
+ from typing import Optional, TypeVar
4
+
5
+ from arclet.alconna import Alconna, Arg, Args, CommandMeta, Option, store_true
6
+ from loguru import logger
7
+ from nonebot_plugin_alconna import Query, on_alconna
8
+ from nonebot_plugin_alconna.uniseg import UniMessage
9
+ from thefuzz import process
10
+
11
+ from .data_source import (
12
+ PMDataItem,
13
+ PMNPluginInfo,
14
+ get_resolved_infos,
15
+ transform_to_pinyin,
16
+ )
17
+ from .templates import detail_templates, func_detail_templates, index_templates
18
+
19
+ alc = Alconna(
20
+ "help",
21
+ Args(
22
+ Arg("plugin?", str, notice="插件序号或名称"),
23
+ Arg("function?", str, notice="插件功能序号或名称"),
24
+ ),
25
+ Option(
26
+ "-H|--show-hidden",
27
+ action=store_true,
28
+ help_text="显示隐藏的插件",
29
+ ),
30
+ meta=CommandMeta(
31
+ description="新一代的图片帮助插件",
32
+ author="LgCookie",
33
+ ),
34
+ )
35
+ m_cls = on_alconna(
36
+ alc,
37
+ aliases={"帮助", "菜单"},
38
+ skip_for_unmatch=False,
39
+ auto_send_output=True,
40
+ use_cmd_start=True,
41
+ )
42
+
43
+
44
+ def get_name_similarities(
45
+ query: str,
46
+ query_pinyin: str,
47
+ choices: list[str],
48
+ choices_pinyin: list[str],
49
+ raw_weight: float = 0.6,
50
+ pinyin_weight: float = 0.4,
51
+ ) -> list[float]:
52
+ similarities: list[float] = []
53
+ raw_iter = process.extractWithoutOrder(query, choices)
54
+ pinyin_iter = process.extractWithoutOrder(query_pinyin, choices_pinyin)
55
+ with suppress(StopIteration):
56
+ while True:
57
+ raw_score = next(raw_iter)[1]
58
+ pinyin_score = next(pinyin_iter)[1]
59
+ similarities.append(raw_weight * raw_score + pinyin_weight * pinyin_score)
60
+ logger.opt(lazy=True).debug(
61
+ "Query: {}, similarities: {}",
62
+ lambda: query,
63
+ lambda: "; ".join(
64
+ f"{choices[i]}: {s}"
65
+ for i, s in sorted(
66
+ enumerate(similarities),
67
+ key=lambda x: x[1],
68
+ reverse=True,
69
+ )
70
+ ),
71
+ )
72
+ return similarities
73
+
74
+
75
+ T = TypeVar("T")
76
+
77
+
78
+ def handle_query_index(query: str, infos: Sequence[T]) -> Optional[tuple[int, T]]:
79
+ if query.isdigit() and query.strip("0"):
80
+ return (
81
+ ((i := qn - 1), infos[i])
82
+ if (1 <= (qn := int(query)) <= len(infos))
83
+ else None
84
+ )
85
+ return None
86
+
87
+
88
+ async def query_plugin(
89
+ infos: list[PMNPluginInfo],
90
+ query: str,
91
+ score_cutoff: float = 60,
92
+ ) -> Optional[tuple[int, PMNPluginInfo]]:
93
+ if r := handle_query_index(query, infos):
94
+ return r
95
+
96
+ choices: list[str] = []
97
+ choices_pinyin: list[str] = []
98
+ for info in infos:
99
+ choices.append(info.name.casefold())
100
+ choices_pinyin.append(info.name_pinyin.casefold())
101
+
102
+ similarities = get_name_similarities(
103
+ query.casefold(),
104
+ transform_to_pinyin(query).casefold(),
105
+ choices,
106
+ choices_pinyin,
107
+ )
108
+ i, s = max(enumerate(similarities), key=lambda x: x[1])
109
+ if s >= score_cutoff:
110
+ return i, infos[i]
111
+ return None
112
+
113
+
114
+ async def query_func_detail(
115
+ pm_data: list[PMDataItem],
116
+ query: str,
117
+ score_cutoff: float = 60,
118
+ ) -> Optional[tuple[int, PMDataItem]]:
119
+ if r := handle_query_index(query, pm_data):
120
+ return r
121
+
122
+ choices: list[str] = []
123
+ choices_pinyin: list[str] = []
124
+ for data in pm_data:
125
+ choices.append(data.func.casefold())
126
+ choices_pinyin.append(data.func_pinyin.casefold())
127
+
128
+ similarities = get_name_similarities(
129
+ query.casefold(),
130
+ transform_to_pinyin(query).casefold(),
131
+ choices,
132
+ choices_pinyin,
133
+ )
134
+ i, s = max(enumerate(similarities), key=lambda x: x[1])
135
+ if s >= score_cutoff:
136
+ return i, pm_data[i]
137
+ return None
138
+
139
+
140
+ @m_cls.handle()
141
+ async def _(
142
+ q_plugin: Query[Optional[str]] = Query("~plugin", None),
143
+ q_function: Query[Optional[str]] = Query("~function", None),
144
+ q_show_hidden: Query[bool] = Query("~show-hidden.value", default=False),
145
+ ):
146
+ infos = await get_resolved_infos()
147
+ if not q_show_hidden.result:
148
+ infos = [x for x in infos if not x.pmn_v.hidden]
149
+
150
+ if not q_plugin.result:
151
+ m = await index_templates.get()(infos)
152
+ await m.finish()
153
+
154
+ r = await query_plugin(infos, q_plugin.result)
155
+ if not r:
156
+ await UniMessage.text("好像没有找到对应插件呢……").finish(reply_to=True)
157
+ info_index, info = r
158
+ if not q_function.result:
159
+ m = await detail_templates.get(info.pmn.template)(info, info_index)
160
+ await m.finish()
161
+
162
+ if not info.pm_data:
163
+ await UniMessage.text(
164
+ f"插件 `{info.name}` 没有详细功能介绍哦",
165
+ ).finish(reply_to=True)
166
+
167
+ if (not (plugin := info.plugin)) or (
168
+ not (pm_data := await info.resolve_pm_data(plugin))
169
+ ):
170
+ await UniMessage.text("啊哦,遇到了意外情况……").finish(reply_to=True)
171
+
172
+ if not q_show_hidden.result:
173
+ pm_data = [x for x in pm_data if not x.hidden]
174
+ r = await query_func_detail(pm_data, q_function.result)
175
+ if not r:
176
+ await UniMessage.text(
177
+ f"好像没有找到插件 `{info.name}` 的对应功能呢……",
178
+ ).finish(reply_to=True)
179
+ func_index, func = r
180
+ m = await func_detail_templates.get(
181
+ func.template,
182
+ )(info, info_index, func, func_index)
183
+ await m.finish()
@@ -0,0 +1,13 @@
1
+ from cookit.pyd import model_with_alias_generator
2
+ from nonebot import get_plugin_config
3
+ from pydantic import BaseModel
4
+
5
+
6
+ @model_with_alias_generator(lambda x: f"pmn_{x}")
7
+ class ConfigModel(BaseModel):
8
+ index_template: str = "default"
9
+ detail_template: str = "default"
10
+ func_detail_template: str = "default"
11
+
12
+
13
+ config: ConfigModel = get_plugin_config(ConfigModel)