Skip to content

Commit e538bcc

Browse files
committed
up
1 parent 4707005 commit e538bcc

File tree

8 files changed

+93
-22
lines changed

8 files changed

+93
-22
lines changed

README.md

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# NoneBot-Plugin-PicMenu-Next
1414

15-
_NoneBot 插件简单描述 ✨_
15+
_新一代的图片帮助插件 ✨_
1616

1717
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
1818
<a href="https://pdm.fming.dev">
@@ -50,7 +50,56 @@ _✨ NoneBot 插件简单描述 ✨_
5050

5151
## 📖 介绍
5252

53-
这里是插件的详细介绍部分
53+
-**美观的图片界面**:直观友好的图片界面
54+
- 🛠️ **PicMenu 兼容**:本插件使用 PicMenu 插件格式的三级菜单(功能详情),兼容 PicMenu 的 `<ft>` 富文本标签(但不太推荐使用)
55+
- 🔍 **支持模糊搜索**:支持通过序号或名称查找插件及功能,并提供插件名称的模糊匹配
56+
- 🔤 **拼音支持**:插件排序与模糊搜索时考虑拼音,提高中文环境下的使用体验
57+
- 📜 **Markdown 支持**:支持 Markdown 格式的帮助信息展示(需要插件开发者主动适配)
58+
- 🔒 **隐藏控制**:默认状态下类型为 `library` 的插件会对普通用户隐藏
59+
- 🎨 **自定义模板**:提供模板开发者注册模板的接口,提供插件开发者自定义某插件使用的详细信息模板的方式,提供配置供用户自定义想要使用的模板
60+
- 🔌 **插件扩展机制**:提供强大的 mixin 支持,允许插件通过中间件方式自定义帮助菜单展示和行为
61+
62+
### 展示图
63+
64+
<details>
65+
<summary>主页面</summary>
66+
67+
![亮色主页](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/light_main.jpg)
68+
![暗色主页](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/dark_main.jpg)
69+
70+
</details>
71+
72+
<details>
73+
<summary>插件详情</summary>
74+
75+
![亮色插件详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/light_detail.jpg)
76+
![暗色插件详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/dark_detail.jpg)
77+
78+
</details>
79+
80+
<details>
81+
<summary>插件详情(带功能详情三级菜单)</summary>
82+
83+
![亮色带三级菜单插件详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/light_with_func.jpg)
84+
![暗色带三级菜单插件详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/dark_with_func.jpg)
85+
86+
</details>
87+
88+
<details>
89+
<summary>功能详情</summary>
90+
91+
![亮色功能详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/light_func_detail.jpg)
92+
![暗色功能详情](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/dark_func_detail.jpg)
93+
94+
</details>
95+
96+
<details>
97+
<summary>Markdown 测试</summary>
98+
99+
![亮色 Markdown 测试](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/light_markdown.jpg)
100+
![暗色 Markdown 测试](https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/picmenu-next/dark_markdown.jpg)
101+
102+
</details>
54103

55104
## 💿 安装
56105

@@ -117,25 +166,22 @@ plugins = [
117166

118167
## ⚙️ 配置
119168

120-
nonebot2 项目的 `.env` 文件中添加下表中的必填配置
169+
NoneBot2 项目的 `.env` 文件中添加下表中的配置
121170

122-
| 配置项 | 必填 | 默认值 | 说明 |
123-
| :------: | :--: | :----: | :------: |
124-
| 配置项 1 ||| 配置说明 |
125-
| 配置项 2 ||| 配置说明 |
171+
| 配置项 | 必填 | 默认值 | 说明 |
172+
| :-----------------------------: | :--: | :-------: | :----------------------------: |
173+
| `PMN_INDEX_TEMPLATE` || `default` | 首页展示模板的名称 |
174+
| `PMN_DETAIL_TEMPLATE` || `default` | 插件详情模板的名称 |
175+
| `PMN_FUNC_DETAIL_TEMPLATE` || `default` | 插件功能详情模板的名称 |
176+
| `PMN_ONLY_SUPERUSER_SEE_HIDDEN` || `False` | 是否仅超级用户可以查看隐藏内容 |
126177

127178
## 🎉 使用
128179

129-
### 指令表
130-
131-
| 指令 | 权限 | 需要@ | 范围 | 说明 |
132-
| :----: | :--: | :---: | :--: | :------: |
133-
| 指令 1 | 主人 || 私聊 | 指令说明 |
134-
| 指令 2 | 群员 || 群聊 | 指令说明 |
180+
发送 `帮助` 指令试试吧!
135181

136-
### 效果图
182+
## 🔧 开发
137183

138-
如果有效果图的话
184+
文档待补充
139185

140186
## 📞 联系
141187

@@ -146,7 +192,9 @@ Telegram:[@lgc2333](https://t.me/lgc2333)
146192

147193
## 💡 鸣谢
148194

149-
如果有要鸣谢的人的话
195+
### [hamo-reid/nonebot_plugin_PicMenu](https://github.com/hamo-reid/nonebot_plugin_PicMenu)
196+
197+
- 灵感来源(?)
150198

151199
## 💰 赞助
152200

nonebot_plugin_picmenu_next/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .data_source import refresh_infos
1212
from .templates import load_builtin_templates
1313

14-
__version__ = "0.1.0.dev2"
14+
__version__ = "0.1.0"
1515
__plugin_meta__ = PluginMetadata(
1616
name="PicMenu Next",
1717
description="新一代的图片帮助插件",

nonebot_plugin_picmenu_next/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async def _(
154154
show_hidden = q_show_hidden.result
155155
if (
156156
show_hidden
157-
and config.only_superuser_show_hidden
157+
and config.only_superuser_see_hidden
158158
and (not await SUPERUSER(bot, ev))
159159
):
160160
await (

nonebot_plugin_picmenu_next/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ConfigModel(BaseModel):
88
index_template: str = "default"
99
detail_template: str = "default"
1010
func_detail_template: str = "default"
11-
only_superuser_show_hidden: bool = False
11+
only_superuser_see_hidden: bool = False
1212

1313

1414
config: ConfigModel = get_plugin_config(ConfigModel)

nonebot_plugin_picmenu_next/data_source/collect.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from nonebot.plugin import Plugin
1313

1414
from ..utils import normalize_plugin_name
15+
from .mixin import chain_mixins, plugin_collect_mixins
1516
from .models import PMNData, PMNPluginExtra, PMNPluginInfo
1617

1718

@@ -77,7 +78,11 @@ async def get_info_from_plugin(plugin: Plugin) -> PMNPluginInfo:
7778
description = (
7879
meta.description
7980
if meta
80-
else (dist.metadata.get("Summary") if (dist := get_dist()) else None)
81+
else (
82+
dist.metadata.get("Summary")
83+
if (dist := get_dist(plugin.module_name))
84+
else None
85+
)
8186
)
8287

8388
pmn = (extra.pmn if extra else None) or PMNData()
@@ -106,6 +111,13 @@ async def _get(p: Plugin):
106111
*(_get(plugin) for plugin in plugins),
107112
)
108113
infos = [x for x in infos if x]
114+
115+
async def final_mixin(infos: list[PMNPluginInfo]):
116+
return infos
117+
118+
mixin_chain = chain_mixins(plugin_collect_mixins.data, final_mixin)
119+
infos = await mixin_chain(infos)
120+
109121
infos.sort(key=lambda x: x.name_pinyin)
110122
logger.success(f"Collected {len(infos)} plugin infos")
111123

nonebot_plugin_picmenu_next/data_source/mixin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
T,
2727
]
2828

29+
PluginCollectMixinNext: TypeAlias = Callable[
30+
[list[PMNPluginInfo]],
31+
Co[list[PMNPluginInfo]],
32+
]
33+
PluginCollectMixin: TypeAlias = MixinFunc[
34+
[list[PMNPluginInfo]],
35+
Co[list[PMNPluginInfo]],
36+
]
37+
2938
SelfMixinNext: TypeAlias = Callable[
3039
[PMNPluginInfo],
3140
Co[PMNPluginInfo],
@@ -102,6 +111,8 @@ def deco(f: T) -> T:
102111
return deco
103112

104113

114+
plugin_collect_mixins: MixinCollector[PluginCollectMixin] = MixinCollector()
115+
105116
self_mixins: SelfMixinCollector[SelfMixin] = SelfMixinCollector()
106117
self_detail_mixins: SelfMixinCollector[PluginDetailMixin] = SelfMixinCollector()
107118

nonebot_plugin_picmenu_next/templates/pw_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def layout(value: str, is_md: bool = False):
7373
if "<ft" in value and "</ft>" in value:
7474
with warning_suppress("Failed to parse PicMenu format rich text"):
7575
txt = transform_ft(value)
76-
return Markup(br(space(txt))) # noqa: S704
76+
return Markup(space(br(txt))) # noqa: S704
7777

7878
return safe_layout(value)
7979

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [{ name = "LgCookie", email = "[email protected]" }]
66
dependencies = [
77
"nonebot2>=2.4.1",
88
"nonebot-plugin-alconna>=0.54.2",
9-
"cookit[jinja,loguru,nonebot-alconna,nonebot-localstore,pw,pyd]>=0.11.5",
9+
"cookit[jinja,loguru,nonebot-alconna,nonebot-localstore,pw,pyd]>=0.11.6",
1010
"pypinyin>=0.54.0",
1111
"jieba>=0.42.1",
1212
"thefuzz>=0.22.1",

0 commit comments

Comments
 (0)