mirror of
https://github.com/LiteyukiStudio/marshoai-melo.git
synced 2024-11-30 09:04:51 +08:00
v0.3.4.2,修改命令参数提取,修复潜在丢失字符bug
This commit is contained in:
parent
a72b9eaf88
commit
da17d5b69d
@ -16,6 +16,7 @@ from .util import *
|
|||||||
from .models import MarshoContext
|
from .models import MarshoContext
|
||||||
from .checkers import superuser_checker, PokeMarshoChecker
|
from .checkers import superuser_checker, PokeMarshoChecker
|
||||||
from .localstore import PluginStore
|
from .localstore import PluginStore
|
||||||
|
import asyncio
|
||||||
config = Config()
|
config = Config()
|
||||||
store = PluginStore(PLUGIN_NAME)
|
store = PluginStore(PLUGIN_NAME)
|
||||||
model_name = config.marshoai_default_model
|
model_name = config.marshoai_default_model
|
||||||
@ -27,6 +28,7 @@ client = ChatCompletionsClient(
|
|||||||
credential=AzureKeyCredential(token)
|
credential=AzureKeyCredential(token)
|
||||||
)
|
)
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
|
lock = asyncio.Lock()
|
||||||
|
|
||||||
logger.info(f"Marsho 的插件数据存储于 : {str(store.get_plugin_data_dir())} 哦~🐾")
|
logger.info(f"Marsho 的插件数据存储于 : {str(store.get_plugin_data_dir())} 哦~🐾")
|
||||||
if config.marshoai_token == "":
|
if config.marshoai_token == "":
|
||||||
@ -78,9 +80,11 @@ async def reset(event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
|||||||
|
|
||||||
@on_start_match("nickname")
|
@on_start_match("nickname")
|
||||||
async def nickname(event: MessageEvent):
|
async def nickname(event: MessageEvent):
|
||||||
|
async with lock:
|
||||||
nicknames = await get_nicknames()
|
nicknames = await get_nicknames()
|
||||||
user_id = str(event.sender.user_id)
|
user_id = str(event.sender.user_id)
|
||||||
name = event.text.lstrip("nickname ")
|
name = event.text.split()[1]
|
||||||
|
# print(user_id, name)
|
||||||
if not name:
|
if not name:
|
||||||
await send_text("你的昵称为:"+str(nicknames[user_id]))
|
await send_text("你的昵称为:"+str(nicknames[user_id]))
|
||||||
return
|
return
|
||||||
@ -96,10 +100,10 @@ async def marsho(event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
|||||||
await marsho_main(event, event.is_group)
|
await marsho_main(event, event.is_group)
|
||||||
|
|
||||||
async def marsho_main(event: Union[GroupMessageEvent, PrivateMessageEvent], is_group: bool):
|
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(USAGE+"\n当前使用的模型:"+model_name)
|
||||||
await send_text(INTRODUCTION)
|
await send_text(INTRODUCTION)
|
||||||
await send_text(str(store.get_plugin_data_dir()))
|
# await send_text(str(store.get_plugin_data_dir()))
|
||||||
return
|
return
|
||||||
# await UniMessage(str(text)).send()
|
# await UniMessage(str(text)).send()
|
||||||
try:
|
try:
|
||||||
@ -127,7 +131,7 @@ async def marsho_main(event: Union[GroupMessageEvent, PrivateMessageEvent], is_g
|
|||||||
for i in event.get_segments("text"):
|
for i in event.get_segments("text"):
|
||||||
if not marsho_string_removed:
|
if not marsho_string_removed:
|
||||||
# 去掉最前面的"marsho "字符串
|
# 去掉最前面的"marsho "字符串
|
||||||
clean_text = i.data["text"].lstrip("marsho ")
|
clean_text = "".join(i.data["text"].split()[1:])
|
||||||
marsho_string_removed = True # 标记文本已处理
|
marsho_string_removed = True # 标记文本已处理
|
||||||
else:
|
else:
|
||||||
clean_text = i.data["text"]
|
clean_text = i.data["text"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
__version__ = "0.3.4.1"
|
__version__ = "0.3.4.2"
|
||||||
VERSION = __version__
|
VERSION = __version__
|
||||||
PLUGIN_NAME = "marshoai"
|
PLUGIN_NAME = "marshoai"
|
||||||
USAGE: str = f"""MarshoAI-Melobot Beta v{__version__} by Asankilp
|
USAGE: str = f"""MarshoAI-Melobot Beta v{__version__} by Asankilp
|
||||||
|
Loading…
Reference in New Issue
Block a user