💡 update docstring

This commit is contained in:
yanyongyu 2021-05-30 11:07:27 +08:00
parent 45e1126f37
commit 916bb5b0e6
4 changed files with 90 additions and 1 deletions

View File

@ -292,7 +292,7 @@ sidebarDepth: 0
### _classmethod_ `new(type_='', rule=None, permission=None, handlers=None, temp=False, priority=1, block=False, *, module=None, default_state=None, default_state_factory=None, expire_time=None)`
### _classmethod_ `new(type_='', rule=None, permission=None, handlers=None, temp=False, priority=1, block=False, *, module=None, expire_time=None, default_state=None, default_state_factory=None, default_parser=None, default_type_updater=None, default_permission_updater=None)`
* **说明**

View File

@ -14,6 +14,80 @@ sidebarDepth: 0
:::
## _class_ `Permission`
基类:`object`
* **说明**
`Matcher` 规则类,当事件传递时,在 `Matcher` 运行前进行检查。
* **示例**
```python
Permission(async_function) | sync_function
# 等价于
from nonebot.utils import run_sync
Permission(async_function, run_sync(sync_function))
```
### `__init__(*checkers)`
* **参数**
* `*checkers: Callable[[Bot, Event], Awaitable[bool]]`: **异步** PermissionChecker
### `checkers`
* **说明**
存储 `PermissionChecker`
* **类型**
* `Set[Callable[[Bot, Event], Awaitable[bool]]]`
### _async_ `__call__(bot, event)`
* **说明**
检查是否满足某个权限
* **参数**
* `bot: Bot`: Bot 对象
* `event: Event`: Event 对象
* **返回**
* `bool`
## `MESSAGE`

View File

@ -9,3 +9,4 @@ NoneBot.permission 模块
.. automodule:: nonebot.permission
:members:
:show-inheritance:
:special-members:

View File

@ -20,6 +20,20 @@ if TYPE_CHECKING:
class Permission:
"""
:说明:
``Matcher`` 规则类当事件传递时 ``Matcher`` 运行前进行检查
:示例:
.. code-block:: python
Permission(async_function) | sync_function
# 等价于
from nonebot.utils import run_sync
Permission(async_function, run_sync(sync_function))
"""
__slots__ = ("checkers",)
def __init__(