diff --git a/konabot/plugins/no_luowen.py b/konabot/plugins/no_luowen.py new file mode 100644 index 0000000..b5eb03c --- /dev/null +++ b/konabot/plugins/no_luowen.py @@ -0,0 +1,44 @@ +import nonebot + +from nonebot.adapters.onebot.v11.bot import Bot +from nonebot.adapters.onebot.v11.event import GroupMessageEvent +from nonebot_plugin_alconna import UniMsg, UniMessage +from pydantic import BaseModel + + +class NoLuowenConfig(BaseModel): + plugin_noluowen_qqid: int = -1 + plugin_noluowen_enable_group: list[int] = [] + +config = nonebot.get_plugin_config(NoLuowenConfig) + + +async def is_luowen_mentioned(evt: GroupMessageEvent, msg: UniMsg) -> bool: + if config.plugin_noluowen_qqid <= 0: + return False + if evt.user_id == config.plugin_noluowen_qqid: + return False + if evt.group_id not in config.plugin_noluowen_enable_group: + return False + txt = msg.extract_plain_text() + if "洛温" not in txt: + return False + if "罗文" in txt: + return False + if "阿特金森" in txt: + return False + return True + +evt_luowen_mentioned = nonebot.on_message(rule=is_luowen_mentioned) + + +@evt_luowen_mentioned.handle() +async def _(evt: GroupMessageEvent, bot: Bot): + msg = ( + UniMessage() + .reply(str(evt.message_id)) + .at(str(config.plugin_noluowen_qqid)) + .text(" 好像有人念错了你的 ID") + ) + await evt_luowen_mentioned.send(await msg.export(bot=bot)) +