v0.3.2,实现nickname

This commit is contained in:
Asankilp 2024-10-25 00:32:53 +08:00
parent b09671093d
commit 0d11be7ade
2 changed files with 25 additions and 5 deletions

View File

@ -45,6 +45,20 @@ async def reset(event: Union[GroupMessageEvent, PrivateMessageEvent]):
context.reset(get_target_id(event), event.is_private) context.reset(get_target_id(event), event.is_private)
await send_text("上下文已重置") await send_text("上下文已重置")
@on_start_match("nickname")
async def nickname(event: MessageEvent):
nicknames = await get_nicknames()
user_id = str(event.sender.user_id)
name = event.text.lstrip("nickname ")
if not name:
await send_text("你的昵称为:"+str(nicknames[user_id]))
return
if name == "reset":
await set_nickname(user_id, "")
await send_text("已重置昵称")
else:
await set_nickname(user_id, name)
await send_text("已设置昵称为:"+name)
@on_start_match("marsho") @on_start_match("marsho")
async def marsho(event: Union[GroupMessageEvent, PrivateMessageEvent]): async def marsho(event: Union[GroupMessageEvent, PrivateMessageEvent]):
@ -60,8 +74,15 @@ async def marsho_main(event: Union[GroupMessageEvent, PrivateMessageEvent], is_g
try: try:
is_support_image_model = model_name.lower() in SUPPORT_IMAGE_MODELS is_support_image_model = model_name.lower() in SUPPORT_IMAGE_MODELS
usermsg = [] if is_support_image_model else "" usermsg = [] if is_support_image_model else ""
user_id = event.sender.user_id user_id = str(event.sender.user_id)
target_id = get_target_id(event) target_id = get_target_id(event)
nicknames = await get_nicknames()
nickname = nicknames.get(user_id, "")
if nickname != "":
nickname_prompt = f"\n*此消息的说话者:{nickname}*"
else:
nickname_prompt = ""
await send_text("*你未设置自己的昵称。推荐使用'nickname [昵称]'命令设置昵称来获得个性化(可能)回答。")
nickname_prompt = "" nickname_prompt = ""
marsho_string_removed = False marsho_string_removed = False
for i in event.get_segments("image"): for i in event.get_segments("image"):
@ -126,4 +147,4 @@ async def poke(event: PokeNotifyEvent, adapter: Adapter): # 尚未实现私聊
class MarshoAI(Plugin): class MarshoAI(Plugin):
version = VERSION version = VERSION
flows = [changemodel,marsho,reset,poke,contexts,praises] flows = [changemodel,marsho,reset,poke,contexts,praises,nickname]

View File

@ -1,16 +1,15 @@
__version__ = "0.3.1.1" __version__ = "0.3.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
用法 用法
marsho <聊天内容> : Marsho 进行对话当模型为 GPT-4o(-mini) 等时可以带上图片进行对话 marsho <聊天内容> : Marsho 进行对话当模型为 GPT-4o(-mini) 等时可以带上图片进行对话
nickname [昵称] : 为自己设定昵称设置昵称后Marsho 会根据你的昵称进行回答使用'nickname reset'命令可清除自己设定的昵称
reset : 重置当前会话的上下文 reset : 重置当前会话的上下文
超级用户命令(均需要加上命令前缀使用): 超级用户命令(均需要加上命令前缀使用):
/changemodel <模型名> : 切换全局 AI 模型 /changemodel <模型名> : 切换全局 AI 模型
/contexts : 返回当前会话的上下文列表 当上下文包含图片时不要使用此命令 /contexts : 返回当前会话的上下文列表 当上下文包含图片时不要使用此命令
/praises : 返回夸赞名单的提示词 /praises : 返回夸赞名单的提示词
本AI的回答"按原样"提供不提供任何担保AI也会犯错请仔细甄别回答的准确性""" 本AI的回答"按原样"提供不提供任何担保AI也会犯错请仔细甄别回答的准确性"""
SUPPORT_IMAGE_MODELS: list = ["gpt-4o","gpt-4o-mini","llama-3.2-90b-vision-instruct","llama-3.2-11b-vision-instruct"] SUPPORT_IMAGE_MODELS: list = ["gpt-4o","gpt-4o-mini","llama-3.2-90b-vision-instruct","llama-3.2-11b-vision-instruct"]