2022-05-14 15:47:33 +08:00
|
|
|
import re
|
2022-06-19 17:24:50 +08:00
|
|
|
from nonebot.adapters.onebot.v11 import GroupMessageEvent, Event
|
2022-05-14 15:47:33 +08:00
|
|
|
from utils.utils import get_message_img_file
|
2021-11-23 21:44:59 +08:00
|
|
|
from .model import WordBank
|
|
|
|
|
|
|
|
|
|
|
2022-06-19 17:24:50 +08:00
|
|
|
async def check(event: Event) -> bool:
|
2021-11-23 21:44:59 +08:00
|
|
|
if isinstance(event, GroupMessageEvent):
|
2022-05-14 15:47:33 +08:00
|
|
|
msg = event.raw_message
|
|
|
|
|
list_img = get_message_img_file(event.json())
|
|
|
|
|
if list_img:
|
|
|
|
|
for img_file in list_img:
|
2022-06-16 00:43:32 +08:00
|
|
|
strinfo = re.compile(f"{img_file},.*?]")
|
2022-05-14 15:47:33 +08:00
|
|
|
msg = strinfo.sub(f'{img_file}]', msg)
|
2022-06-19 17:24:50 +08:00
|
|
|
strinfo_face = re.compile(f",type=sticker]")
|
|
|
|
|
msg = strinfo_face.sub(f']', msg)
|
|
|
|
|
return bool(await WordBank.check(event.group_id, msg,))
|
2021-11-23 21:44:59 +08:00
|
|
|
return False
|