Skip to content

Commit

Permalink
🔀 Merge pull request #54
Browse files Browse the repository at this point in the history
fix temp matcher delete
  • Loading branch information
yanyongyu committed Nov 16, 2020
2 parents 2e2f3ee + 8524c32 commit bc8833c
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 84 deletions.
17 changes: 0 additions & 17 deletions docs/api/exception.md
Expand Up @@ -83,23 +83,6 @@ sidebarDepth: 0



## _exception_ `ExpiredException`

基类:`Exception`


* **说明**

指示 NoneBot 当前 `Matcher` 已失效。



* **用法**

`Matcher` 运行前检查时抛出。



## _exception_ `StopPropagation`

基类:`Exception`
Expand Down
135 changes: 135 additions & 0 deletions docs/api/message.md
Expand Up @@ -6,3 +6,138 @@ sidebarDepth: 0
# NoneBot.message 模块

## 事件处理

NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供了多个插槽以进行事件的预处理等。


## `event_preprocessor(func)`


* **说明**

事件预处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。



* **参数**

事件预处理函数接收三个参数。


* `bot: Bot`: Bot 对象


* `event: Event`: Event 对象


* `state: dict`: 当前 State



## `event_postprocessor(func)`


* **说明**

事件后处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。



* **参数**

事件后处理函数接收三个参数。


* `bot: Bot`: Bot 对象


* `event: Event`: Event 对象


* `state: dict`: 当前事件运行前 State



## `run_preprocessor(func)`


* **说明**

运行预处理。装饰一个函数,使它在每次事件响应器运行前执行。



* **参数**

运行预处理函数接收四个参数。


* `matcher: Matcher`: 当前要运行的事件响应器


* `bot: Bot`: Bot 对象


* `event: Event`: Event 对象


* `state: dict`: 当前 State



## `run_postprocessor(func)`


* **说明**

运行后处理。装饰一个函数,使它在每次事件响应器运行后执行。



* **参数**

运行后处理函数接收五个参数。


* `matcher: Matcher`: 运行完毕的事件响应器


* `exception: Optional[Exception]`: 事件响应器运行错误(如果存在)


* `bot: Bot`: Bot 对象


* `event: Event`: Event 对象


* `state: dict`: 当前 State



## _async_ `handle_event(bot, event)`


* **说明**

处理一个事件。调用该函数以实现分发事件。



* **参数**


* `bot: Bot`: Bot 对象


* `event: Event`: Event 对象



* **示例**


```python
import asyncio
asyncio.create_task(handle_event(bot, event))
```
4 changes: 2 additions & 2 deletions docs/api/typing.md
Expand Up @@ -163,13 +163,13 @@ sidebarDepth: 0

* **类型**

`Callable[[Matcher, List[Any], Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
`Callable[[Matcher, Optional[Exception], Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`



* **说明**

事件响应器运行前预处理函数 RunPostProcessor 类型,第二个参数包含运行时产生的错误以及 `ExpiredException`, `StopPropagation` (如果存在)
事件响应器运行前预处理函数 RunPostProcessor 类型,第二个参数为运行时产生的错误(如果存在



Expand Down
19 changes: 0 additions & 19 deletions nonebot/exception.py
Expand Up @@ -9,12 +9,6 @@
from nonebot.typing import List, Type, Optional


class _ExceptionContainer(Exception):

def __init__(self, exceptions: List[Type[Exception]]) -> None:
self.exceptions = exceptions


class IgnoredException(Exception):
"""
:说明:
Expand Down Expand Up @@ -79,19 +73,6 @@ class FinishedException(Exception):
pass


class ExpiredException(Exception):
"""
:说明:
指示 NoneBot 当前 ``Matcher`` 已失效。
:用法:
当 ``Matcher`` 运行前检查时抛出。
"""
pass


class StopPropagation(Exception):
"""
:说明:
Expand Down

0 comments on commit bc8833c

Please sign in to comment.