diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index 82724b68..cf380e25 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -222,6 +222,10 @@ async def nickname(event: Event, name=None): await set_nickname(user_id, "") await nickname_cmd.finish("已重置昵称") else: + if len(name) > config.marshoai_nickname_limit: + await nickname_cmd.finish( + "昵称超出长度限制:" + str(config.marshoai_nickname_limit) + ) await set_nickname(user_id, name) await nickname_cmd.finish("已设置昵称为:" + name) diff --git a/nonebot_plugin_marshoai/config.py b/nonebot_plugin_marshoai/config.py index 7a919027..7b2950bb 100644 --- a/nonebot_plugin_marshoai/config.py +++ b/nonebot_plugin_marshoai/config.py @@ -46,6 +46,7 @@ class ConfigModel(BaseModel): marshoai_temperature: float | None = None marshoai_max_tokens: int | None = None marshoai_top_p: float | None = None + marshoai_nickname_limit: int = 16 marshoai_additional_image_models: list = [] marshoai_tencent_secretid: str | None = None marshoai_tencent_secretkey: str | None = None diff --git a/nonebot_plugin_marshoai/config_example.yaml b/nonebot_plugin_marshoai/config_example.yaml index da9a8550..5c38d68d 100644 --- a/nonebot_plugin_marshoai/config_example.yaml +++ b/nonebot_plugin_marshoai/config_example.yaml @@ -42,6 +42,8 @@ marshoai_enable_plugins: true # 是否启用插件功能。 marshoai_load_builtin_tools: true # 是否加载内置工具。 +marshoai_nickname_limit: 16 # 昵称长度限制。 + marshoai_toolset_dir: [] # 工具集路径。 marshoai_disabled_toolkits: [] # 已禁用的工具包列表。