mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
✨ 添加小真寻的口癖配置
This commit is contained in:
parent
ae5df38c21
commit
8aeeb0953d
28
zhenxun/builtin_plugins/catchphrase.py
Normal file
28
zhenxun/builtin_plugins/catchphrase.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from nonebot.adapters import Bot
|
||||||
|
|
||||||
|
from zhenxun.services.log import logger
|
||||||
|
from zhenxun.configs.config import Config
|
||||||
|
|
||||||
|
Config.add_plugin_config(
|
||||||
|
"catchphrase",
|
||||||
|
"CATCHPHRASE",
|
||||||
|
"",
|
||||||
|
help="小真寻的口癖,在文本末尾添加指定文字~",
|
||||||
|
default_value="",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@Bot.on_calling_api
|
||||||
|
async def handle_api_call(bot: Bot, api: str, data: dict[str, Any]):
|
||||||
|
if api == "send_msg":
|
||||||
|
catchphrase = Config.get_config("catchphrase", "CATCHPHRASE")
|
||||||
|
if catchphrase and (message := data.get("message")):
|
||||||
|
for i in range(len(message) - 1, -1, -1):
|
||||||
|
if message[i].type == "text":
|
||||||
|
message[i].data["text"] += catchphrase
|
||||||
|
logger.debug(
|
||||||
|
f"文本: {message[i].data['text']} 添加口癖: {catchphrase}"
|
||||||
|
)
|
||||||
|
break
|
||||||
Loading…
Reference in New Issue
Block a user