connect driver-adapter-matcher

This commit is contained in:
yanyongyu
2020-07-11 17:32:03 +08:00
parent ea21d6ffcc
commit d616290626
10 changed files with 280 additions and 20 deletions

View File

@ -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