mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-03 02:24:51 +08:00
commit
9ea80abf8c
@ -10,17 +10,23 @@ _running_matcher: Dict[str, int] = {}
|
|||||||
|
|
||||||
@run_preprocessor
|
@run_preprocessor
|
||||||
async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):
|
async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):
|
||||||
session_id = event.get_session_id()
|
try:
|
||||||
event_id = id(event)
|
session_id = event.get_session_id()
|
||||||
|
except Exception:
|
||||||
if _running_matcher.get(session_id, None) != event_id:
|
return
|
||||||
|
current_event_id = id(event)
|
||||||
|
event_id = _running_matcher.get(session_id, None)
|
||||||
|
if event_id and event_id != current_event_id:
|
||||||
raise IgnoredException("Annother matcher running")
|
raise IgnoredException("Annother matcher running")
|
||||||
|
|
||||||
_running_matcher[session_id] = event_id
|
_running_matcher[session_id] = current_event_id
|
||||||
|
|
||||||
|
|
||||||
@run_postprocessor
|
@run_postprocessor
|
||||||
async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):
|
async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):
|
||||||
session_id = event.get_session_id()
|
try:
|
||||||
|
session_id = event.get_session_id()
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
if session_id in _running_matcher:
|
if session_id in _running_matcher:
|
||||||
del _running_matcher[session_id]
|
del _running_matcher[session_id]
|
||||||
|
Loading…
Reference in New Issue
Block a user