✏️ add missing annotationo

This commit is contained in:
yanyongyu 2021-12-07 02:16:18 +08:00
parent 47d4909b31
commit b64b02bb45
2 changed files with 2 additions and 37 deletions

View File

@ -14,7 +14,7 @@ from nonebot.drivers import (
class Adapter(abc.ABC):
def __init__(self, driver: Driver, **kwargs: Any):
self.driver = driver
self.driver: Driver = driver
self.bots: Dict[str, Bot] = {}
@classmethod

View File

@ -44,7 +44,7 @@ class Bot(abc.ABC):
* ``self_id: str``: 机器人 ID
* ``request: HTTPConnection``: request 连接对象
"""
self.adapter = adapter
self.adapter: "Adapter" = adapter
self.self_id: str = self_id
"""机器人 ID"""
@ -59,41 +59,6 @@ class Bot(abc.ABC):
def config(self) -> Config:
return self.adapter.config
@classmethod
@abc.abstractmethod
async def check_permission(
cls, driver: Driver, request: HTTPConnection
) -> Tuple[Optional[str], Optional[HTTPResponse]]:
"""
:说明:
检查连接请求是否合法的函数如果合法则返回当前连接 ``唯一标识符``通常为机器人 ID如果不合法则抛出 ``RequestDenied`` 异常
:参数:
* ``driver: Driver``: Driver 对象
* ``request: HTTPConnection``: request 请求详情
:返回:
- ``Optional[str]``: 连接唯一标识符``None`` 代表连接不合法
- ``Optional[HTTPResponse]``: HTTP 上报响应
"""
raise NotImplementedError
@abc.abstractmethod
async def handle_message(self, message: bytes):
"""
:说明:
处理上报消息的函数转换为 ``Event`` 事件后调用 ``nonebot.message.handle_event`` 进一步处理事件
:参数:
* ``message: bytes``: 收到的上报消息
"""
raise NotImplementedError
async def call_api(self, api: str, **data: Any) -> Any:
"""
:说明: