🐛 Fix: Bot Hook 没有捕获跳过异常 (#905)

This commit is contained in:
Ju4tCode
2022-04-04 10:35:14 +08:00
committed by GitHub
parent 494b9c625d
commit 2f3324ce0c
12 changed files with 333 additions and 303 deletions

View File

@ -3,6 +3,7 @@ from contextlib import AsyncExitStack
from typing import Any, Set, Tuple, Union, NoReturn, Optional, Coroutine
from nonebot.dependencies import Dependent
from nonebot.utils import run_coro_with_catch
from nonebot.exception import SkippedException
from nonebot.typing import T_DependencyCache, T_PermissionChecker
@ -10,13 +11,6 @@ from .adapter import Bot, Event
from .params import BotParam, EventParam, DependParam, DefaultParam
async def _run_coro_with_catch(coro: Coroutine[Any, Any, Any]):
try:
return await coro
except SkippedException:
return False
class Permission:
"""{ref}`nonebot.matcher.Matcher` 权限类。
@ -72,13 +66,15 @@ class Permission:
return True
results = await asyncio.gather(
*(
_run_coro_with_catch(
run_coro_with_catch(
checker(
bot=bot,
event=event,
stack=stack,
dependency_cache=dependency_cache,
)
),
(SkippedException,),
False,
)
for checker in self.checkers
),