添加内置工具插件,支持获取已加载插件列表和读取本地文件内容功能

This commit is contained in:
2024-12-17 02:34:59 +08:00
parent d8ac06419b
commit 1e58944edc
10 changed files with 116 additions and 8 deletions

View File

@ -1,8 +1,6 @@
"""该功能目前~~正在开发中~~开发基本完成,暂时~~不~~可用,受影响的文件夹 `plugin`, `plugins`
"""
from nonebot import logger
from .func_call import *
from .load import *
from .models import *

View File

@ -39,12 +39,12 @@ class Caller:
if self.bot is None or self.event is None:
return False, "Context is None"
if self._permission and not await self._permission(self.bot, self.event):
return False, "Permission Denied 权限不足"
return False, "告诉用户 Permission Denied 权限不足"
if self.state is None:
return False, "State is None"
if self._rule and not await self._rule(self.bot, self.event, self.state):
return False, "Rule Denied 规则不匹配"
return False, "告诉用户 Rule Denied 规则不匹配"
return True, ""
@ -92,10 +92,10 @@ class Caller:
self.func = async_wrap(func) # type: ignore
if module := inspect.getmodule(func):
module_name = module.__name__ + "."
module_name = module.__name__.split(".")[-1] + "."
else:
module_name = ""
logger.opt(colors=True).info(
logger.opt(colors=True).debug(
f"<y>加载函数 {module_name}{func.__name__}: {self._description}</y>"
)

View File

@ -19,6 +19,8 @@ _plugins: dict[str, Plugin] = {}
__all__ = [
"load_plugin",
"load_plugins",
"get_plugin",
"get_plugins",
"_plugins",
]