mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-17 16:20:05 +08:00
27 lines
677 B
Python
27 lines
677 B
Python
|
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
from .log import logger
|
||
|
from .event import Event
|
||
|
from .matcher import matchers
|
||
|
|
||
|
|
||
|
async def handle_message(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):
|
||
|
continue
|
||
|
|
||
|
matcher = Matcher()
|
||
|
if Matcher.temp:
|
||
|
del matchers[priority][index]
|
||
|
|
||
|
try:
|
||
|
await matcher.run(bot, event)
|
||
|
except Exception as e:
|
||
|
logger.exception(e)
|
||
|
return
|