在罗文被念错时提醒他
This commit is contained in:
44
konabot/plugins/no_luowen.py
Normal file
44
konabot/plugins/no_luowen.py
Normal file
@ -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))
|
||||||
|
|
||||||
Reference in New Issue
Block a user