添加多字符喵对一些符号的响应
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import datetime
|
||||
from math import ceil
|
||||
|
||||
from nonebot import get_plugin_config
|
||||
from nonebot.adapters import Event
|
||||
from nonebot_plugin_alconna import (
|
||||
Alconna,
|
||||
@ -14,7 +13,6 @@ from nonebot_plugin_alconna import (
|
||||
UniMessage,
|
||||
on_alconna,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
from konabot.common.longtask import DepLongTaskTarget
|
||||
from konabot.common.nb.exc import BotExceptionMessage
|
||||
@ -40,15 +38,6 @@ from konabot.plugins.poster.service import broadcast
|
||||
PUZZLE_PAGE_SIZE = 10
|
||||
|
||||
|
||||
class PuzzleConfig(BaseModel):
|
||||
plugin_puzzle_manager: list[str] = []
|
||||
plugin_puzzle_admin: list[str] = []
|
||||
plugin_puzzle_playgroup: list[str] = []
|
||||
|
||||
|
||||
config = get_plugin_config(PuzzleConfig)
|
||||
|
||||
|
||||
async def check_puzzle(
|
||||
manager: PuzzleManager,
|
||||
perm: DepPermManager,
|
||||
|
||||
@ -6,6 +6,7 @@ from konabot.common.nb.match_keyword import match_keyword
|
||||
|
||||
evt_nya = on_message(rule=match_keyword("喵"))
|
||||
|
||||
|
||||
@evt_nya.handle()
|
||||
async def _():
|
||||
await evt_nya.send(await UniMessage().text("喵").export())
|
||||
@ -25,8 +26,9 @@ NYA_SYMBOL_MAPPING = {
|
||||
"~": "~",
|
||||
"~": "~",
|
||||
" ": " ",
|
||||
"\n": "\n",
|
||||
}
|
||||
NYA_SYMBOL_KEEP = "—¹₁²₂³₃⁴₄⁵₅⁶₆⁷₇⁸₈⁹₉⁰₀\n"
|
||||
NYA_SYMBOL_MAPPING.update((k, k) for k in NYA_SYMBOL_KEEP)
|
||||
|
||||
|
||||
async def has_nya(msg: UniMsg) -> bool:
|
||||
@ -49,10 +51,10 @@ async def has_nya(msg: UniMsg) -> bool:
|
||||
|
||||
evt_nya_v2 = on_message(rule=has_nya)
|
||||
|
||||
|
||||
@evt_nya_v2.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)
|
||||
|
||||
await UniMessage.text("".join((NYA_SYMBOL_MAPPING.get(c, "") for c in text))).send(
|
||||
evt
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user