From 0b4b975e1b54ab365a4b270f50c01391e646cd5c Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Fri, 21 Jun 2024 20:16:54 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8DBus.emit=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=B5=8B=E8=AF=95=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把background参数放kwargs里了,通过单开一个参数解决。 --- mirai_onebot/event/bus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mirai_onebot/event/bus.py b/mirai_onebot/event/bus.py index 5a50f0d..914a012 100644 --- a/mirai_onebot/event/bus.py +++ b/mirai_onebot/event/bus.py @@ -47,7 +47,7 @@ def decorator(func: Callable) -> Callable: return decorator - async def emit(self, event: Union[Type[EventBase], str], *args, **kwargs) -> None: + async def emit(self, event: Union[Type[EventBase], str], background=True, *args, **kwargs) -> None: """触发事件 Args: @@ -58,5 +58,5 @@ async def emit(self, event: Union[Type[EventBase], str], *args, **kwargs) -> Non if event in self._subscribers.keys(): tasks = [asyncio.create_task(subscriber(*args, **kwargs)) for subscriber in self._subscribers[event]] - if kwargs.get('background', True) is False: + if not background: await asyncio.wait(tasks)