修复缺少「喵」字匹配的问题
This commit is contained in:
@ -4,11 +4,11 @@ from nonebot_plugin_alconna import UniMessage, UniMsg, Text
|
|||||||
|
|
||||||
from konabot.common.nb.match_keyword import match_keyword
|
from konabot.common.nb.match_keyword import match_keyword
|
||||||
|
|
||||||
evt = on_message(rule=match_keyword("喵"))
|
evt_nya_v2 = on_message(rule=match_keyword("喵"))
|
||||||
|
|
||||||
@evt.handle()
|
@evt_nya_v2.handle()
|
||||||
async def _():
|
async def _():
|
||||||
await evt.send(await UniMessage().text("喵").export())
|
await evt_nya_v2.send(await UniMessage().text("喵").export())
|
||||||
|
|
||||||
|
|
||||||
NYA_SYMBOL_MAPPING = {
|
NYA_SYMBOL_MAPPING = {
|
||||||
@ -34,18 +34,22 @@ async def has_nya(msg: UniMsg) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
text = msg.extract_plain_text()
|
text = msg.extract_plain_text()
|
||||||
if any(((char not in NYA_SYMBOL_MAPPING) for char in text)):
|
|
||||||
return False
|
|
||||||
|
|
||||||
if len(text) <= 1:
|
if len(text) <= 1:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if "喵" not in text:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if any(((char not in NYA_SYMBOL_MAPPING) for char in text)):
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
evt = on_message(rule=has_nya)
|
evt_nya_v2 = on_message(rule=has_nya)
|
||||||
|
|
||||||
@evt.handle()
|
@evt_nya_v2.handle()
|
||||||
async def _(msg: UniMsg, evt: Event):
|
async def _(msg: UniMsg, evt: Event):
|
||||||
text = msg.extract_plain_text()
|
text = msg.extract_plain_text()
|
||||||
await UniMessage.text(''.join(
|
await UniMessage.text(''.join(
|
||||||
|
|||||||
Reference in New Issue
Block a user