关于插件分类的一些想法 #94
Replies: 5 comments 7 replies
-
|
现在b1更新的影响就非常清楚了:A类插件全灭 |
Beta Was this translation helpful? Give feedback.
-
|
或许可以给插件商店的打上类似的tag? |
Beta Was this translation helpful? Give feedback.
-
|
取决于插件商店的受众,商店插件的绝大部分应该都归属于A类。
所述的B类、C类插件一般需配合插件的 README 食用,一般也能通过插件的显示名称或说明看出来。
同时商店插件的
|
Beta Was this translation helpful? Give feedback.
-
|
我感觉这个想法其实非常不错... 但是主要是现在这个前端也就只有 @yanyongyu 一个人写 我觉得前端需要加的功能:
同时在发布以上功能的同时, 我们需要添加几个预定义的tag |
Beta Was this translation helpful? Give feedback.
-
import asyncio
from typing import cast
import traceback
import nonebot
from nonebot.adapters.onebot.v11 import Adapter
from fastapi import Query, FastAPI
from fastapi.responses import UJSONResponse, HTMLResponse
app = nonebot.get_asgi()
app = cast(FastAPI, app)
driver = nonebot.get_driver()
@app.get('/')
async def handle_get():
return HTMLResponse(f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nonebot</title>
</head>
<body>
<h1 align="center"><strong>nonebot{nonebot.__version__} is runing!</strong></h1>
<p align="center">Vist <a href="https://v2.nonebot.dev">noneot document</a> for more information</p>
<hr/>
<p align="center">Yours, nonebot</p>
</body>
</html>""")
@app.get('/bots')
async def get_bots():
ret = {"bots": []}
[ret["bots"].append(qq) for qq in driver._clients]
return ret
@app.get("/disconnect")
async def disconnect(bot: str = Query(...)) -> UJSONResponse:
try:
adapter = nonebot.get_driver()._adapters[Adapter.get_name()]
adapter = cast(Adapter, adapter)
ws = adapter.connections[bot]
await ws.close()
adapter.connections.pop(bot, None)
adapter.bot_disconnect(nonebot.get_bot(bot))
nonebot.logger.info(f"disconnect bot: {bot}")
except Exception as e:
return UJSONResponse({"msg": "no such bot", "exc": traceback.format_exc()}, 404)
else:
return UJSONResponse({"msg": "ok"}, 200)一个简单的C类插件,可以查看状态之类的,释放连接 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
似乎目前的插件商店对各种插件的分类还比较混乱,各种tag都有,于是,以下提出一种根据插件功能进行分类的想法
主要分为三类插件
A类插件: 注册matcher,可以对特定的
event做出响应的(简单来说就是会说话的那种插件)。目前商店的大部分是这种类型的B类插件: 使用
export功能,在自己的命名空间注册一些对象,方便别的插件使用的,主要用于跨插件调用。典型的,有定时器插件C类插件:在
serverapp上做文章的,这种插件主要是利用了nonebot作为webserver的功能,以实现别的需求。典型的,有文档插件这种分类就能一目了然的知道插件的性质了。比如,B类插件绝对没法开箱即用,它们的功能是辅助别的插件。通常,B类插件要优先于A类插件加载,否则可能出问题。又比如,正向driver就不能使用文档插件,(因为正向是舔狗,根本没有serverapp对象)。

当然,这种分类也不是绝对的,如果一个插件有多种功能,那就应该是混合型的插件,(比如AB类,自己能说话的同时向别的插件暴露了一些功能)
Beta Was this translation helpful? Give feedback.
All reactions