MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / get_driver

Function get_driver

nonebot/__init__.py:71–90  ·  view source on GitHub ↗

获取全局 {ref}`nonebot.drivers.Driver` 实例。 可用于在计划任务的回调等情形中获取当前 {ref}`nonebot.drivers.Driver` 实例。 返回: 全局 {ref}`nonebot.drivers.Driver` 对象 异常: ValueError: 全局 {ref}`nonebot.drivers.Driver` 对象尚未初始化 ({ref}`nonebot.init ` 尚未调用) 用法: ```pytho

()

Source from the content-addressed store, hash-verified

69
70
71def get_driver() -> Driver:
72 """获取全局 {ref}`nonebot.drivers.Driver` 实例。
73
74 可用于在计划任务的回调等情形中获取当前 {ref}`nonebot.drivers.Driver` 实例。
75
76 返回:
77 全局 {ref}`nonebot.drivers.Driver` 对象
78
79 异常:
80 ValueError: 全局 {ref}`nonebot.drivers.Driver` 对象尚未初始化
81 ({ref}`nonebot.init <nonebot.init>` 尚未调用)
82
83 用法:
84 ```python
85 driver = nonebot.get_driver()
86 ```
87 """
88 if _driver is None:
89 raise ValueError("NoneBot has not been initialized.")
90 return _driver
91
92
93@overload

Callers 13

commandFunction · 0.90
shell_commandFunction · 0.90
get_plugin_configFunction · 0.90
test_get_driverFunction · 0.90
test_get_asgiFunction · 0.90
test_get_appFunction · 0.90
test_runFunction · 0.90
test_get_botFunction · 0.90
get_adaptersFunction · 0.85
get_appFunction · 0.85
get_asgiFunction · 0.85
get_botsFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_get_driverFunction · 0.72
test_get_asgiFunction · 0.72
test_get_appFunction · 0.72
test_runFunction · 0.72
test_get_botFunction · 0.72