From 014e9c9a71d3a173cc0905dd66244aca2da71cea Mon Sep 17 00:00:00 2001 From: passthem Date: Wed, 25 Feb 2026 13:40:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=96=B5=E7=9A=84=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/nya_echo/__init__.py | 46 +++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/konabot/plugins/nya_echo/__init__.py b/konabot/plugins/nya_echo/__init__.py index cce5a62..b92471d 100644 --- a/konabot/plugins/nya_echo/__init__.py +++ b/konabot/plugins/nya_echo/__init__.py @@ -1,5 +1,6 @@ from nonebot import on_message -from nonebot_plugin_alconna import UniMessage +from nonebot.internal.adapter import Event +from nonebot_plugin_alconna import UniMessage, UniMsg, Text from konabot.common.nb.match_keyword import match_keyword @@ -8,3 +9,46 @@ evt = on_message(rule=match_keyword("喵")) @evt.handle() async def _(): await evt.send(await UniMessage().text("喵").export()) + + +NYA_SYMBOL_MAPPING = { + "喵": "喵", + "!": "!", + "?": "!", + "!": "!", + "?": "!", + ",": ",", + ",": ",", + ".": ".", + "。": "。", + "…": "…", + "~": "~", + "~": "~", + " ": " ", + "\n": "\n", +} + + +async def has_nya(msg: UniMsg) -> bool: + if any((not isinstance(seg, Text) for seg in msg)): + return False + + text = msg.extract_plain_text() + if any(((char not in NYA_SYMBOL_MAPPING) for char in text)): + return False + + if len(text) <= 1: + return False + + return True + + +evt = on_message(rule=has_nya) + +@evt.handle() +async def _(msg: UniMsg, evt: Event): + text = msg.extract_plain_text() + await UniMessage.text(''.join( + (NYA_SYMBOL_MAPPING.get(c, '') for c in text) + )).send(evt) + From ba15841836262b9e7aa9f86275799095d9428e74 Mon Sep 17 00:00:00 2001 From: passthem Date: Wed, 25 Feb 2026 13:49:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E3=80=8C=E5=96=B5=E3=80=8D=E5=AD=97=E5=8C=B9=E9=85=8D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/nya_echo/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/konabot/plugins/nya_echo/__init__.py b/konabot/plugins/nya_echo/__init__.py index b92471d..54251bc 100644 --- a/konabot/plugins/nya_echo/__init__.py +++ b/konabot/plugins/nya_echo/__init__.py @@ -4,11 +4,11 @@ from nonebot_plugin_alconna import UniMessage, UniMsg, Text 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 _(): - await evt.send(await UniMessage().text("喵").export()) + await evt_nya_v2.send(await UniMessage().text("喵").export()) NYA_SYMBOL_MAPPING = { @@ -34,18 +34,22 @@ async def has_nya(msg: UniMsg) -> bool: return False text = msg.extract_plain_text() - if any(((char not in NYA_SYMBOL_MAPPING) for char in text)): - return False if len(text) <= 1: return False + if "喵" not in text: + return False + + if any(((char not in NYA_SYMBOL_MAPPING) for char in text)): + return False + 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): text = msg.extract_plain_text() await UniMessage.text(''.join( From 3ddf81e7def8271bc3b70eda457a5646ea64b028 Mon Sep 17 00:00:00 2001 From: passthem Date: Wed, 25 Feb 2026 13:52:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E9=81=AE=E8=94=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/nya_echo/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/konabot/plugins/nya_echo/__init__.py b/konabot/plugins/nya_echo/__init__.py index 54251bc..fe6f07d 100644 --- a/konabot/plugins/nya_echo/__init__.py +++ b/konabot/plugins/nya_echo/__init__.py @@ -4,11 +4,11 @@ from nonebot_plugin_alconna import UniMessage, UniMsg, Text from konabot.common.nb.match_keyword import match_keyword -evt_nya_v2 = on_message(rule=match_keyword("喵")) +evt_nya = on_message(rule=match_keyword("喵")) -@evt_nya_v2.handle() +@evt_nya.handle() async def _(): - await evt_nya_v2.send(await UniMessage().text("喵").export()) + await evt_nya.send(await UniMessage().text("喵").export()) NYA_SYMBOL_MAPPING = {