添加多字符喵对一些符号的响应
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
from nonebot import get_plugin_config
|
|
||||||
from nonebot.adapters import Event
|
from nonebot.adapters import Event
|
||||||
from nonebot_plugin_alconna import (
|
from nonebot_plugin_alconna import (
|
||||||
Alconna,
|
Alconna,
|
||||||
@ -14,7 +13,6 @@ from nonebot_plugin_alconna import (
|
|||||||
UniMessage,
|
UniMessage,
|
||||||
on_alconna,
|
on_alconna,
|
||||||
)
|
)
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from konabot.common.longtask import DepLongTaskTarget
|
from konabot.common.longtask import DepLongTaskTarget
|
||||||
from konabot.common.nb.exc import BotExceptionMessage
|
from konabot.common.nb.exc import BotExceptionMessage
|
||||||
@ -40,15 +38,6 @@ from konabot.plugins.poster.service import broadcast
|
|||||||
PUZZLE_PAGE_SIZE = 10
|
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(
|
async def check_puzzle(
|
||||||
manager: PuzzleManager,
|
manager: PuzzleManager,
|
||||||
perm: DepPermManager,
|
perm: DepPermManager,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from konabot.common.nb.match_keyword import match_keyword
|
|||||||
|
|
||||||
evt_nya = on_message(rule=match_keyword("喵"))
|
evt_nya = on_message(rule=match_keyword("喵"))
|
||||||
|
|
||||||
|
|
||||||
@evt_nya.handle()
|
@evt_nya.handle()
|
||||||
async def _():
|
async def _():
|
||||||
await evt_nya.send(await UniMessage().text("喵").export())
|
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:
|
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 = on_message(rule=has_nya)
|
||||||
|
|
||||||
|
|
||||||
@evt_nya_v2.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((NYA_SYMBOL_MAPPING.get(c, "") for c in text))).send(
|
||||||
(NYA_SYMBOL_MAPPING.get(c, '') for c in text)
|
evt
|
||||||
)).send(evt)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user