We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Feature: 替换 toml 读取方式
在 python 3.11 中已经支持了读取 toml 配置。https://docs.python.org/3/library/tomllib.html

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nonebot/plugin/load.py`
Content:
```
1 """本模块定义插件加载接口。
2 
3 FrontMatter:
4     sidebar_position: 1
5     description: nonebot.plugin.load 模块
6 """
7 import json
8 from pathlib import Path
9 from types import ModuleType
10 from typing import Set, Union, Iterable, Optional
11 
12 import tomlkit
13 
14 from nonebot.utils import path_to_module_name
15 
16 from .plugin import Plugin
17 from .manager import PluginManager
18 from . import _managers, get_plugin, _module_name_to_plugin_name
19 
20 
21 def load_plugin(module_path: Union[str, Path]) -> Optional[Plugin]:
22     """加载单个插件，可以是本地插件或是通过 `pip` 安装的插件。
23 
24     参数:
25         module_path: 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
26     """
27     module_path = (
28         path_to_module_name(module_path)
29         if isinstance(module_path, Path)
30         else module_path
31     )
32     manager = PluginManager([module_path])
33     _managers.append(manager)
34     return manager.load_plugin(module_path)
35 
36 
37 def load_plugins(*plugin_dir: str) -> Set[Plugin]:
38     """导入文件夹下多个插件，以 `_` 开头的插件不会被导入!
39 
40     参数:
41         plugin_dir: 文件夹路径
42     """
43     manager = PluginManager(search_path=plugin_dir)
44     _managers.append(manager)
45     return manager.load_all_plugins()
46 
47 
48 def load_all_plugins(
49     module_path: Iterable[str], plugin_dir: Iterable[str]
50 ) -> Set[Plugin]:
51     """导入指定列表中的插件以及指定目录下多个插件，以 `_` 开头的插件不会被导入!
52 
53     参数:
54         module_path: 指定插件集合
55         plugin_dir: 指定文件夹路径集合
56     """
57     manager = PluginManager(module_path, plugin_dir)
58     _managers.append(manager)
59     return manager.load_all_plugins()
60 
61 
62 def load_from_json(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
63     """导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件，以 `_` 开头的插件不会被导入!
64 
65     参数:
66         file_path: 指定 json 文件路径
67         encoding: 指定 json 文件编码
68 
69     用法:
70         ```json title=plugins.json
71         {
72             "plugins": ["some_plugin"],
73             "plugin_dirs": ["some_dir"]
74         }
75         ```
76 
77         ```python
78         nonebot.load_from_json("plugins.json")
79         ```
80     """
81     with open(file_path, "r", encoding=encoding) as f:
82         data = json.load(f)
83     if not isinstance(data, dict):
84         raise TypeError("json file must contains a dict!")
85     plugins = data.get("plugins")
86     plugin_dirs = data.get("plugin_dirs")
87     assert isinstance(plugins, list), "plugins must be a list of plugin name"
88     assert isinstance(plugin_dirs, list), "plugin_dirs must be a list of directories"
89     return load_all_plugins(set(plugins), set(plugin_dirs))
90 
91 
92 def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
93     """导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件，以 `_` 开头的插件不会被导入!
94 
95     参数:
96         file_path: 指定 toml 文件路径
97         encoding: 指定 toml 文件编码
98 
99     用法:
100         ```toml title=pyproject.toml
101         [tool.nonebot]
102         plugins = ["some_plugin"]
103         plugin_dirs = ["some_dir"]
104         ```
105 
106         ```python
107         nonebot.load_from_toml("pyproject.toml")
108         ```
109     """
110     with open(file_path, "r", encoding=encoding) as f:
111         data = tomlkit.parse(f.read())  # type: ignore
112 
113     nonebot_data = data.get("tool", {}).get("nonebot")
114     if nonebot_data is None:
115         raise ValueError("Cannot find '[tool.nonebot]' in given toml file!")
116     if not isinstance(nonebot_data, dict):
117         raise TypeError("'[tool.nonebot]' must be a Table!")
118     plugins = nonebot_data.get("plugins", [])
119     plugin_dirs = nonebot_data.get("plugin_dirs", [])
120     assert isinstance(plugins, list), "plugins must be a list of plugin name"
121     assert isinstance(plugin_dirs, list), "plugin_dirs must be a list of directories"
122     return load_all_plugins(plugins, plugin_dirs)
123 
124 
125 def load_builtin_plugin(name: str) -> Optional[Plugin]:
126     """导入 NoneBot 内置插件。
127 
128     参数:
129         name: 插件名称
130     """
131     return load_plugin(f"nonebot.plugins.{name}")
132 
133 
134 def load_builtin_plugins(*plugins: str) -> Set[Plugin]:
135     """导入多个 NoneBot 内置插件。
136 
137     参数:
138         plugins: 插件名称列表
139     """
140     return load_all_plugins([f"nonebot.plugins.{p}" for p in plugins], [])
141 
142 
143 def _find_manager_by_name(name: str) -> Optional[PluginManager]:
144     for manager in reversed(_managers):
145         if name in manager.plugins or name in manager.searched_plugins:
146             return manager
147 
148 
149 def require(name: str) -> ModuleType:
150     """获取一个插件的导出内容。
151 
152     如果为 `load_plugins` 文件夹导入的插件，则为文件(夹)名。
153 
154     参数:
155         name: 插件名，即 {ref}`nonebot.plugin.plugin.Plugin.name`。
156 
157     异常:
158         RuntimeError: 插件无法加载
159     """
160     plugin = get_plugin(_module_name_to_plugin_name(name))
161     if not plugin:
162         if manager := _find_manager_by_name(name):
163             plugin = manager.load_plugin(name)
164         else:
165             plugin = load_plugin(name)
166     if not plugin:
167         raise RuntimeError(f'Cannot load plugin "{name}"!')
168     return plugin.module
169
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nonebot/plugin/load.py b/nonebot/plugin/load.py
--- a/nonebot/plugin/load.py
+++ b/nonebot/plugin/load.py
@@ -9,14 +9,17 @@
 from types import ModuleType
 from typing import Set, Union, Iterable, Optional
 
-import tomlkit
-
 from nonebot.utils import path_to_module_name
 
 from .plugin import Plugin
 from .manager import PluginManager
 from . import _managers, get_plugin, _module_name_to_plugin_name
 
+try:
+    import tomllib  # pyright: reportMissingImports=false
+except ModuleNotFoundError:
+    import tomli as tomllib
+
 
 def load_plugin(module_path: Union[str, Path]) -> Optional[Plugin]:
     """加载单个插件，可以是本地插件或是通过 `pip` 安装的插件。
@@ -108,7 +111,7 @@
         ```
     """
     with open(file_path, "r", encoding=encoding) as f:
-        data = tomlkit.parse(f.read())  # type: ignore
+        data = tomllib.loads(f.read())
 
     nonebot_data = data.get("tool", {}).get("nonebot")
     if nonebot_data is None:

{"golden_diff": "diff --git a/nonebot/plugin/load.py b/nonebot/plugin/load.py\n--- a/nonebot/plugin/load.py\n+++ b/nonebot/plugin/load.py\n@@ -9,14 +9,17 @@\n from types import ModuleType\n from typing import Set, Union, Iterable, Optional\n \n-import tomlkit\n-\n from nonebot.utils import path_to_module_name\n \n from .plugin import Plugin\n from .manager import PluginManager\n from . import _managers, get_plugin, _module_name_to_plugin_name\n \n+try:\n+    import tomllib  # pyright: reportMissingImports=false\n+except ModuleNotFoundError:\n+    import tomli as tomllib\n+\n \n def load_plugin(module_path: Union[str, Path]) -> Optional[Plugin]:\n     \"\"\"\u52a0\u8f7d\u5355\u4e2a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u662f\u672c\u5730\u63d2\u4ef6\u6216\u662f\u901a\u8fc7 `pip` \u5b89\u88c5\u7684\u63d2\u4ef6\u3002\n@@ -108,7 +111,7 @@\n         ```\n     \"\"\"\n     with open(file_path, \"r\", encoding=encoding) as f:\n-        data = tomlkit.parse(f.read())  # type: ignore\n+        data = tomllib.loads(f.read())\n \n     nonebot_data = data.get(\"tool\", {}).get(\"nonebot\")\n     if nonebot_data is None:\n", "issue": "Feature: \u66ff\u6362 toml \u8bfb\u53d6\u65b9\u5f0f\n\u5728 python 3.11 \u4e2d\u5df2\u7ecf\u652f\u6301\u4e86\u8bfb\u53d6 toml \u914d\u7f6e\u3002https://docs.python.org/3/library/tomllib.html\n", "before_files": [{"content": "\"\"\"\u672c\u6a21\u5757\u5b9a\u4e49\u63d2\u4ef6\u52a0\u8f7d\u63a5\u53e3\u3002\n\nFrontMatter:\n    sidebar_position: 1\n    description: nonebot.plugin.load \u6a21\u5757\n\"\"\"\nimport json\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import Set, Union, Iterable, Optional\n\nimport tomlkit\n\nfrom nonebot.utils import path_to_module_name\n\nfrom .plugin import Plugin\nfrom .manager import PluginManager\nfrom . import _managers, get_plugin, _module_name_to_plugin_name\n\n\ndef load_plugin(module_path: Union[str, Path]) -> Optional[Plugin]:\n    \"\"\"\u52a0\u8f7d\u5355\u4e2a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u662f\u672c\u5730\u63d2\u4ef6\u6216\u662f\u901a\u8fc7 `pip` \u5b89\u88c5\u7684\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        module_path: \u63d2\u4ef6\u540d\u79f0 `path.to.your.plugin` \u6216\u63d2\u4ef6\u8def\u5f84 `pathlib.Path(path/to/your/plugin)`\n    \"\"\"\n    module_path = (\n        path_to_module_name(module_path)\n        if isinstance(module_path, Path)\n        else module_path\n    )\n    manager = PluginManager([module_path])\n    _managers.append(manager)\n    return manager.load_plugin(module_path)\n\n\ndef load_plugins(*plugin_dir: str) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6587\u4ef6\u5939\u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        plugin_dir: \u6587\u4ef6\u5939\u8def\u5f84\n    \"\"\"\n    manager = PluginManager(search_path=plugin_dir)\n    _managers.append(manager)\n    return manager.load_all_plugins()\n\n\ndef load_all_plugins(\n    module_path: Iterable[str], plugin_dir: Iterable[str]\n) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a\u5217\u8868\u4e2d\u7684\u63d2\u4ef6\u4ee5\u53ca\u6307\u5b9a\u76ee\u5f55\u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        module_path: \u6307\u5b9a\u63d2\u4ef6\u96c6\u5408\n        plugin_dir: \u6307\u5b9a\u6587\u4ef6\u5939\u8def\u5f84\u96c6\u5408\n    \"\"\"\n    manager = PluginManager(module_path, plugin_dir)\n    _managers.append(manager)\n    return manager.load_all_plugins()\n\n\ndef load_from_json(file_path: str, encoding: str = \"utf-8\") -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a json \u6587\u4ef6\u4e2d\u7684 `plugins` \u4ee5\u53ca `plugin_dirs` \u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        file_path: \u6307\u5b9a json \u6587\u4ef6\u8def\u5f84\n        encoding: \u6307\u5b9a json \u6587\u4ef6\u7f16\u7801\n\n    \u7528\u6cd5:\n        ```json title=plugins.json\n        {\n            \"plugins\": [\"some_plugin\"],\n            \"plugin_dirs\": [\"some_dir\"]\n        }\n        ```\n\n        ```python\n        nonebot.load_from_json(\"plugins.json\")\n        ```\n    \"\"\"\n    with open(file_path, \"r\", encoding=encoding) as f:\n        data = json.load(f)\n    if not isinstance(data, dict):\n        raise TypeError(\"json file must contains a dict!\")\n    plugins = data.get(\"plugins\")\n    plugin_dirs = data.get(\"plugin_dirs\")\n    assert isinstance(plugins, list), \"plugins must be a list of plugin name\"\n    assert isinstance(plugin_dirs, list), \"plugin_dirs must be a list of directories\"\n    return load_all_plugins(set(plugins), set(plugin_dirs))\n\n\ndef load_from_toml(file_path: str, encoding: str = \"utf-8\") -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a toml \u6587\u4ef6 `[tool.nonebot]` \u4e2d\u7684 `plugins` \u4ee5\u53ca `plugin_dirs` \u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        file_path: \u6307\u5b9a toml \u6587\u4ef6\u8def\u5f84\n        encoding: \u6307\u5b9a toml \u6587\u4ef6\u7f16\u7801\n\n    \u7528\u6cd5:\n        ```toml title=pyproject.toml\n        [tool.nonebot]\n        plugins = [\"some_plugin\"]\n        plugin_dirs = [\"some_dir\"]\n        ```\n\n        ```python\n        nonebot.load_from_toml(\"pyproject.toml\")\n        ```\n    \"\"\"\n    with open(file_path, \"r\", encoding=encoding) as f:\n        data = tomlkit.parse(f.read())  # type: ignore\n\n    nonebot_data = data.get(\"tool\", {}).get(\"nonebot\")\n    if nonebot_data is None:\n        raise ValueError(\"Cannot find '[tool.nonebot]' in given toml file!\")\n    if not isinstance(nonebot_data, dict):\n        raise TypeError(\"'[tool.nonebot]' must be a Table!\")\n    plugins = nonebot_data.get(\"plugins\", [])\n    plugin_dirs = nonebot_data.get(\"plugin_dirs\", [])\n    assert isinstance(plugins, list), \"plugins must be a list of plugin name\"\n    assert isinstance(plugin_dirs, list), \"plugin_dirs must be a list of directories\"\n    return load_all_plugins(plugins, plugin_dirs)\n\n\ndef load_builtin_plugin(name: str) -> Optional[Plugin]:\n    \"\"\"\u5bfc\u5165 NoneBot \u5185\u7f6e\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        name: \u63d2\u4ef6\u540d\u79f0\n    \"\"\"\n    return load_plugin(f\"nonebot.plugins.{name}\")\n\n\ndef load_builtin_plugins(*plugins: str) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u591a\u4e2a NoneBot \u5185\u7f6e\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        plugins: \u63d2\u4ef6\u540d\u79f0\u5217\u8868\n    \"\"\"\n    return load_all_plugins([f\"nonebot.plugins.{p}\" for p in plugins], [])\n\n\ndef _find_manager_by_name(name: str) -> Optional[PluginManager]:\n    for manager in reversed(_managers):\n        if name in manager.plugins or name in manager.searched_plugins:\n            return manager\n\n\ndef require(name: str) -> ModuleType:\n    \"\"\"\u83b7\u53d6\u4e00\u4e2a\u63d2\u4ef6\u7684\u5bfc\u51fa\u5185\u5bb9\u3002\n\n    \u5982\u679c\u4e3a `load_plugins` \u6587\u4ef6\u5939\u5bfc\u5165\u7684\u63d2\u4ef6\uff0c\u5219\u4e3a\u6587\u4ef6(\u5939)\u540d\u3002\n\n    \u53c2\u6570:\n        name: \u63d2\u4ef6\u540d\uff0c\u5373 {ref}`nonebot.plugin.plugin.Plugin.name`\u3002\n\n    \u5f02\u5e38:\n        RuntimeError: \u63d2\u4ef6\u65e0\u6cd5\u52a0\u8f7d\n    \"\"\"\n    plugin = get_plugin(_module_name_to_plugin_name(name))\n    if not plugin:\n        if manager := _find_manager_by_name(name):\n            plugin = manager.load_plugin(name)\n        else:\n            plugin = load_plugin(name)\n    if not plugin:\n        raise RuntimeError(f'Cannot load plugin \"{name}\"!')\n    return plugin.module\n", "path": "nonebot/plugin/load.py"}], "after_files": [{"content": "\"\"\"\u672c\u6a21\u5757\u5b9a\u4e49\u63d2\u4ef6\u52a0\u8f7d\u63a5\u53e3\u3002\n\nFrontMatter:\n    sidebar_position: 1\n    description: nonebot.plugin.load \u6a21\u5757\n\"\"\"\nimport json\nfrom pathlib import Path\nfrom types import ModuleType\nfrom typing import Set, Union, Iterable, Optional\n\nfrom nonebot.utils import path_to_module_name\n\nfrom .plugin import Plugin\nfrom .manager import PluginManager\nfrom . import _managers, get_plugin, _module_name_to_plugin_name\n\ntry:\n    import tomllib  # pyright: reportMissingImports=false\nexcept ModuleNotFoundError:\n    import tomli as tomllib\n\n\ndef load_plugin(module_path: Union[str, Path]) -> Optional[Plugin]:\n    \"\"\"\u52a0\u8f7d\u5355\u4e2a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u662f\u672c\u5730\u63d2\u4ef6\u6216\u662f\u901a\u8fc7 `pip` \u5b89\u88c5\u7684\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        module_path: \u63d2\u4ef6\u540d\u79f0 `path.to.your.plugin` \u6216\u63d2\u4ef6\u8def\u5f84 `pathlib.Path(path/to/your/plugin)`\n    \"\"\"\n    module_path = (\n        path_to_module_name(module_path)\n        if isinstance(module_path, Path)\n        else module_path\n    )\n    manager = PluginManager([module_path])\n    _managers.append(manager)\n    return manager.load_plugin(module_path)\n\n\ndef load_plugins(*plugin_dir: str) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6587\u4ef6\u5939\u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        plugin_dir: \u6587\u4ef6\u5939\u8def\u5f84\n    \"\"\"\n    manager = PluginManager(search_path=plugin_dir)\n    _managers.append(manager)\n    return manager.load_all_plugins()\n\n\ndef load_all_plugins(\n    module_path: Iterable[str], plugin_dir: Iterable[str]\n) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a\u5217\u8868\u4e2d\u7684\u63d2\u4ef6\u4ee5\u53ca\u6307\u5b9a\u76ee\u5f55\u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        module_path: \u6307\u5b9a\u63d2\u4ef6\u96c6\u5408\n        plugin_dir: \u6307\u5b9a\u6587\u4ef6\u5939\u8def\u5f84\u96c6\u5408\n    \"\"\"\n    manager = PluginManager(module_path, plugin_dir)\n    _managers.append(manager)\n    return manager.load_all_plugins()\n\n\ndef load_from_json(file_path: str, encoding: str = \"utf-8\") -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a json \u6587\u4ef6\u4e2d\u7684 `plugins` \u4ee5\u53ca `plugin_dirs` \u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        file_path: \u6307\u5b9a json \u6587\u4ef6\u8def\u5f84\n        encoding: \u6307\u5b9a json \u6587\u4ef6\u7f16\u7801\n\n    \u7528\u6cd5:\n        ```json title=plugins.json\n        {\n            \"plugins\": [\"some_plugin\"],\n            \"plugin_dirs\": [\"some_dir\"]\n        }\n        ```\n\n        ```python\n        nonebot.load_from_json(\"plugins.json\")\n        ```\n    \"\"\"\n    with open(file_path, \"r\", encoding=encoding) as f:\n        data = json.load(f)\n    if not isinstance(data, dict):\n        raise TypeError(\"json file must contains a dict!\")\n    plugins = data.get(\"plugins\")\n    plugin_dirs = data.get(\"plugin_dirs\")\n    assert isinstance(plugins, list), \"plugins must be a list of plugin name\"\n    assert isinstance(plugin_dirs, list), \"plugin_dirs must be a list of directories\"\n    return load_all_plugins(set(plugins), set(plugin_dirs))\n\n\ndef load_from_toml(file_path: str, encoding: str = \"utf-8\") -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u6307\u5b9a toml \u6587\u4ef6 `[tool.nonebot]` \u4e2d\u7684 `plugins` \u4ee5\u53ca `plugin_dirs` \u4e0b\u591a\u4e2a\u63d2\u4ef6\uff0c\u4ee5 `_` \u5f00\u5934\u7684\u63d2\u4ef6\u4e0d\u4f1a\u88ab\u5bfc\u5165!\n\n    \u53c2\u6570:\n        file_path: \u6307\u5b9a toml \u6587\u4ef6\u8def\u5f84\n        encoding: \u6307\u5b9a toml \u6587\u4ef6\u7f16\u7801\n\n    \u7528\u6cd5:\n        ```toml title=pyproject.toml\n        [tool.nonebot]\n        plugins = [\"some_plugin\"]\n        plugin_dirs = [\"some_dir\"]\n        ```\n\n        ```python\n        nonebot.load_from_toml(\"pyproject.toml\")\n        ```\n    \"\"\"\n    with open(file_path, \"r\", encoding=encoding) as f:\n        data = tomllib.loads(f.read())\n\n    nonebot_data = data.get(\"tool\", {}).get(\"nonebot\")\n    if nonebot_data is None:\n        raise ValueError(\"Cannot find '[tool.nonebot]' in given toml file!\")\n    if not isinstance(nonebot_data, dict):\n        raise TypeError(\"'[tool.nonebot]' must be a Table!\")\n    plugins = nonebot_data.get(\"plugins\", [])\n    plugin_dirs = nonebot_data.get(\"plugin_dirs\", [])\n    assert isinstance(plugins, list), \"plugins must be a list of plugin name\"\n    assert isinstance(plugin_dirs, list), \"plugin_dirs must be a list of directories\"\n    return load_all_plugins(plugins, plugin_dirs)\n\n\ndef load_builtin_plugin(name: str) -> Optional[Plugin]:\n    \"\"\"\u5bfc\u5165 NoneBot \u5185\u7f6e\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        name: \u63d2\u4ef6\u540d\u79f0\n    \"\"\"\n    return load_plugin(f\"nonebot.plugins.{name}\")\n\n\ndef load_builtin_plugins(*plugins: str) -> Set[Plugin]:\n    \"\"\"\u5bfc\u5165\u591a\u4e2a NoneBot \u5185\u7f6e\u63d2\u4ef6\u3002\n\n    \u53c2\u6570:\n        plugins: \u63d2\u4ef6\u540d\u79f0\u5217\u8868\n    \"\"\"\n    return load_all_plugins([f\"nonebot.plugins.{p}\" for p in plugins], [])\n\n\ndef _find_manager_by_name(name: str) -> Optional[PluginManager]:\n    for manager in reversed(_managers):\n        if name in manager.plugins or name in manager.searched_plugins:\n            return manager\n\n\ndef require(name: str) -> ModuleType:\n    \"\"\"\u83b7\u53d6\u4e00\u4e2a\u63d2\u4ef6\u7684\u5bfc\u51fa\u5185\u5bb9\u3002\n\n    \u5982\u679c\u4e3a `load_plugins` \u6587\u4ef6\u5939\u5bfc\u5165\u7684\u63d2\u4ef6\uff0c\u5219\u4e3a\u6587\u4ef6(\u5939)\u540d\u3002\n\n    \u53c2\u6570:\n        name: \u63d2\u4ef6\u540d\uff0c\u5373 {ref}`nonebot.plugin.plugin.Plugin.name`\u3002\n\n    \u5f02\u5e38:\n        RuntimeError: \u63d2\u4ef6\u65e0\u6cd5\u52a0\u8f7d\n    \"\"\"\n    plugin = get_plugin(_module_name_to_plugin_name(name))\n    if not plugin:\n        if manager := _find_manager_by_name(name):\n            plugin = manager.load_plugin(name)\n        else:\n            plugin = load_plugin(name)\n    if not plugin:\n        raise RuntimeError(f'Cannot load plugin \"{name}\"!')\n    return plugin.module\n", "path": "nonebot/plugin/load.py"}]}