mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-27 16:21:28 +00:00
@ -60,6 +60,19 @@ class BaseBot(abc.ABC):
|
||||
async def check_permission(cls, driver: Driver, connection_type: str,
|
||||
headers: dict,
|
||||
body: Optional[dict]) -> Union[str, NoReturn]:
|
||||
"""
|
||||
:说明:
|
||||
检查连接请求是否合法的函数,如果合法则返回当前连接 ``唯一标识符``,通常为机器人 ID;如果不合法则抛出 ``RequestDenied`` 异常。
|
||||
:参数:
|
||||
* ``driver: Driver``: Driver 对象
|
||||
* ``connection_type: str``: 连接类型
|
||||
* ``headers: dict``: 请求头
|
||||
* ``body: Optional[dict]``: 请求数据,WebSocket 连接该部分为空
|
||||
:返回:
|
||||
- ``str``: 连接唯一标识符
|
||||
:异常:
|
||||
- ``RequestDenied``: 请求非法
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
@ -84,7 +97,7 @@ class BaseBot(abc.ABC):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
await bot.call_api("send_msg", data={"message": "hello world"})
|
||||
await bot.call_api("send_msg", message="hello world"})
|
||||
await bot.send_msg(message="hello world")
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
Reference in New Issue
Block a user