mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🎨 笨蛋检测更多规则移入rule
This commit is contained in:
parent
4bf5f880ba
commit
d8e437dbb7
@ -7,6 +7,7 @@ from nonebot.matcher import Matcher
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
@ -30,8 +31,17 @@ __plugin_meta__ = PluginMetadata(
|
||||
)
|
||||
|
||||
|
||||
async def rule(event: Event, message: UniMsg) -> bool:
|
||||
async def rule(event: Event, message: UniMsg, session: Uninfo) -> bool:
|
||||
group_id = session.group.id if session.group else None
|
||||
text = message.extract_plain_text().strip()
|
||||
if await BanConsole.is_ban(session.user.id, group_id):
|
||||
return False
|
||||
if group_id:
|
||||
if await BanConsole.is_ban(None, group_id):
|
||||
return False
|
||||
if g := await GroupConsole.get_group(group_id):
|
||||
if g.level < 0:
|
||||
return False
|
||||
return event.is_tome() and bool(text and len(text) < 20)
|
||||
|
||||
|
||||
@ -43,18 +53,7 @@ _path = IMAGE_PATH / "_base" / "laugh"
|
||||
|
||||
@_matcher.handle()
|
||||
async def _(matcher: Matcher, message: UniMsg, session: EventSession):
|
||||
gid = session.id3 or session.id2
|
||||
if await BanConsole.is_ban(session.id1, gid):
|
||||
return
|
||||
if gid:
|
||||
if await BanConsole.is_ban(None, gid):
|
||||
return
|
||||
if g := await GroupConsole.get_group(gid):
|
||||
if g.level < 0:
|
||||
return
|
||||
if text := message.extract_plain_text().strip():
|
||||
if len(text) > 100:
|
||||
return
|
||||
text = message.extract_plain_text().strip()
|
||||
if plugin := await PluginInfo.get_or_none(
|
||||
name=text,
|
||||
load_status=True,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user