From da17d5b69d3c9b8213d36108ea7f8f2d3bd08b10 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Tue, 29 Oct 2024 00:38:25 +0800 Subject: [PATCH] =?UTF-8?q?v0.3.4.2=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8F=82=E6=95=B0=E6=8F=90=E5=8F=96=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=BD=9C=E5=9C=A8=E4=B8=A2=E5=A4=B1=E5=AD=97=E7=AC=A6?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marshoai/__plugin__.py | 12 ++++++++---- marshoai/constants.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/marshoai/__plugin__.py b/marshoai/__plugin__.py index d6d3dfd..47045db 100644 --- a/marshoai/__plugin__.py +++ b/marshoai/__plugin__.py @@ -16,6 +16,7 @@ from .util import * from .models import MarshoContext from .checkers import superuser_checker, PokeMarshoChecker from .localstore import PluginStore +import asyncio config = Config() store = PluginStore(PLUGIN_NAME) model_name = config.marshoai_default_model @@ -27,6 +28,7 @@ client = ChatCompletionsClient( credential=AzureKeyCredential(token) ) logger = get_logger() +lock = asyncio.Lock() logger.info(f"Marsho 的插件数据存储于 : {str(store.get_plugin_data_dir())} 哦~🐾") if config.marshoai_token == "": @@ -78,9 +80,11 @@ async def reset(event: Union[GroupMessageEvent, PrivateMessageEvent]): @on_start_match("nickname") async def nickname(event: MessageEvent): + async with lock: nicknames = await get_nicknames() user_id = str(event.sender.user_id) - name = event.text.lstrip("nickname ") + name = event.text.split()[1] + # print(user_id, name) if not name: await send_text("你的昵称为:"+str(nicknames[user_id])) return @@ -96,10 +100,10 @@ async def marsho(event: Union[GroupMessageEvent, PrivateMessageEvent]): await marsho_main(event, event.is_group) async def marsho_main(event: Union[GroupMessageEvent, PrivateMessageEvent], is_group: bool): - if event.text.lstrip("marsho") == "": + if len(event.text.split()) == 1: await send_text(USAGE+"\n当前使用的模型:"+model_name) await send_text(INTRODUCTION) - await send_text(str(store.get_plugin_data_dir())) + # await send_text(str(store.get_plugin_data_dir())) return # await UniMessage(str(text)).send() try: @@ -127,7 +131,7 @@ async def marsho_main(event: Union[GroupMessageEvent, PrivateMessageEvent], is_g for i in event.get_segments("text"): if not marsho_string_removed: # 去掉最前面的"marsho "字符串 - clean_text = i.data["text"].lstrip("marsho ") + clean_text = "".join(i.data["text"].split()[1:]) marsho_string_removed = True # 标记文本已处理 else: clean_text = i.data["text"] diff --git a/marshoai/constants.py b/marshoai/constants.py index ca0ed6a..aa194f5 100644 --- a/marshoai/constants.py +++ b/marshoai/constants.py @@ -1,4 +1,4 @@ -__version__ = "0.3.4.1" +__version__ = "0.3.4.2" VERSION = __version__ PLUGIN_NAME = "marshoai" USAGE: str = f"""MarshoAI-Melobot Beta v{__version__} by Asankilp @@ -21,4 +21,4 @@ REASONING_MODELS: list = ["o1-preview","o1-mini"] INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI,名叫小棉~🐾! 我是基于 Melobot 酱开发的哦~ 我的代码在这里哦~↓↓↓ -https://github.com/LiteyukiStudio/marshoai-melo""" \ No newline at end of file +https://github.com/LiteyukiStudio/marshoai-melo"""