mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 19:11:00 +00:00
connect driver-adapter-matcher
This commit is contained in:
@ -6,13 +6,19 @@ from nonebot.event import Event
|
||||
from nonebot.matcher import matchers
|
||||
|
||||
|
||||
async def handle_message(bot, event: Event):
|
||||
async def handle_event(bot, event: Event):
|
||||
# TODO: PreProcess
|
||||
|
||||
for priority in sorted(matchers.keys()):
|
||||
for index in range(len(matchers[priority])):
|
||||
Matcher = matchers[priority][index]
|
||||
if not Matcher.check_rule(event):
|
||||
try:
|
||||
if not Matcher.check_rule(event):
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"Rule check failed for matcher {Matcher}. Ignored.")
|
||||
logger.exception(e)
|
||||
continue
|
||||
|
||||
matcher = Matcher()
|
||||
@ -22,5 +28,6 @@ async def handle_message(bot, event: Event):
|
||||
try:
|
||||
await matcher.run(bot, event)
|
||||
except Exception as e:
|
||||
logger.error(f"Running matcher {matcher} failed.")
|
||||
logger.exception(e)
|
||||
return
|
||||
|
Reference in New Issue
Block a user