Skip to content

Commit

Permalink
更新维护
Browse files Browse the repository at this point in the history
  • Loading branch information
huanxin996 committed Jun 16, 2024
1 parent df36181 commit 434e056
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 41 deletions.
Binary file removed dist/nonebot-plugin-hx-yinying-1.3.13.tar.gz
Binary file not shown.
Binary file added dist/nonebot-plugin-hx-yinying-1.3.14.tar.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 28 additions & 23 deletions nonebot_plugin_hx_yinying/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
},
)


#拉一坨大的😋
#awa--------味大,无需多盐!
logger.opt(colors=True).success( f"""
<fg #60F5F5> ------------------<Y>幻歆v{hx_config.hx_version}</Y>----------------</fg #60F5F5>
Expand Down Expand Up @@ -65,7 +67,6 @@
logger.error("未设置核心配置?!,请检查你配置里的yinying_appid和yinying_token")
else:
scheduler.add_job(func=check_update,trigger='interval',hours=3,id="huanxin996")
logger.opt(colors=True).success(f"【Hx】定时检测更新启动。")
logger.opt(colors=True).success("【Hx】加载核心配置成功,定时检测更新启动。")

#检测更新
Expand All @@ -76,12 +77,11 @@

#尝试检查错误模块
if os.path.exists(f"{log_dir}/file/error_report/hx_error.html"):
logger.success("已加载错误报告模块")
logger.success("【Hx】已加载错误报告模块")
else:
logger.error("未找到错误报告模块的文件,尝试下载。。。")
get_file()


#根据订阅信息注册定时任务
try:
extent = int(len(dy_list))
Expand Down Expand Up @@ -113,12 +113,12 @@
set_global_config = on_command("设置全局配置", aliases={"设置配置全局","globalset"},rule=Rule(chek_rule_admin), priority=0, block=True)
model_list = on_command("模型列表", aliases={"modellist","chat模型列表"},rule=Rule(chek_rule_base), priority=0, block=True)
model_handoff = on_command("切换模型", aliases={"qhmodel","切换chat模型","模型切换"},rule=Rule(chek_rule_base), priority=0, block=True)
easycyber_set = on_command("easycyber", aliases={"easycyber设置","hxworld"},rule=Rule(chek_rule_base), priority=0, block=True)
cyber_set = on_command("cyber", aliases={"cyber设置","Hxworld"},rule=Rule(chek_rule_base), priority=0, block=True)
admin_set = on_command("控制台操作", aliases={"管理控制台","setstart"},rule=Rule(chek_rule_admin), priority=0, block=True)
verision = on_command("确认版本", aliases={"旅行伙伴确认","版本确认"},rule=Rule(chek_rule_base), priority=0, block=True)
character = on_command("sd", aliases={"旅行伙伴加入","设定加入"},rule=Rule(chek_rule_base), priority=0, block=True)
chat_ne = on_command("加入订阅", aliases={"旅行伙伴觉醒","订阅加入"},rule=Rule(chek_rule_base), priority=0, block=True)
easycyber_set = on_command("easycyber", aliases={"easycyber设置","hxworld"},rule=Rule(chek_rule_base), priority=10, block=True)
cyber_set = on_command("cyber", aliases={"cyber设置","Hxworld"},rule=Rule(chek_rule_base), priority=10, block=True)
admin_set = on_command("控制台操作", aliases={"管理控制台","setstart"},rule=Rule(chek_rule_admin), priority=1, block=True)
verision = on_command("确认版本", aliases={"旅行伙伴确认","版本确认"},rule=Rule(chek_rule_base), priority=9, block=True)
character = on_command("sd", aliases={"旅行伙伴加入","设定加入"},rule=Rule(chek_rule_base), priority=8, block=True)
chat_ne = on_command("加入订阅", aliases={"旅行伙伴觉醒","订阅加入"},rule=Rule(chek_rule_base), priority=15, block=True)
time_noend = on_command("切换时间线", aliases={"切换模式"},rule=Rule(chek_rule_base), priority=0, block=True)
gloubalblack_add = on_command("全局拉黑", aliases={"银影不要理"},rule=Rule(chek_rule_admin), priority=0, block=True)
banword_add = on_command("添加违禁词", aliases={"banword","违禁词添加"},rule=Rule(chek_rule_admin), priority=0, block=True)
Expand Down Expand Up @@ -515,7 +515,7 @@ async def history(bot: Bot, event: MessageEvent,events: Event):
#获取模型列表
@model_list.handle()
async def list(matcher: Matcher, event: MessageEvent):
msg = "1.yinyingllm-v1\n2.yinyingllm-v2\n3.yinyingllm-v3\n4.cyberfurry-001\n5.easycyberfurry-001\n切换模型请发送:切换模型(序号)"
msg = "1.yinyingllm-v1\n2.yinyingllm-v3\n3.yinyingllm-v4\n4.cyberfurry-001\n5.easycyberfurry-001\n切换模型请发送:切换模型(序号)"
await send_msg(matcher, event, msg)

#模型切换方面
Expand Down Expand Up @@ -578,11 +578,15 @@ async def _(matcher: Matcher, bot:Bot, event: MessageEvent, s: T_State,events: E
s["last"] = ""
if s["last"]:
if s["last"] == "增加":
if text == "" or not text:
s["last"] = "增加"
msg = "无效昵称"
await send_msg_reject(matcher,event,msg)
if text == "Hx" or text == "HX" or text == "幻歆":
s["last"] = True
msg = "easycyber预设“Hx”不能删除或修改,如要改动请改源码"
await send_msg(matcher,event,msg)
elif text in easycyber_in_tg(text,False) or text in easycyber_in(text,False) or not text:
elif text in easycyber_in_tg() or text in easycyber_in():
s["last"] = "增加"
msg = "该预设角色名称已经存在,请不要重复使用该昵称,请重新输入,如需退出请发送退出"
await send_msg_reject(matcher,event,msg)
Expand Down Expand Up @@ -775,7 +779,7 @@ async def _(matcher: Matcher, bot:Bot, event: MessageEvent, s: T_State,events: E
s["last"] = True
msg = "cyber预设“Hx”不能删除或修改,如要改动请改源码"
await send_msg(matcher,event,msg)
elif text in cyber_in_tg(text,False) or text in cyber_in(text,False):
elif text in cyber_in_tg() or text in cyber_in():
s["last"] = True
msg = "该预设角色名称已经存在,请不要重复使用该昵称."
await send_msg(matcher,event,msg)
Expand Down Expand Up @@ -924,50 +928,51 @@ async def _(matcher: Matcher, bot:Bot, event: MessageEvent, s: T_State):
if s["last"] == "通过":
msg = "请输入要通过的预设名称,如果不知道建议先get下列表"
if text == "easycyber":
s["last"] == "easyber"
s["last"] = "easyber"
await send_msg_reject(matcher,event,msg)
elif text == "cyber":
s["last"] == "cyber"
s["last"] = "cyber"
await send_msg_reject(matcher,event,msg)

if s["last"] == "easyber":
json_1 = easycyber_in_tg(False,False)
s["last"] = True
json_1 = easycyber_in_tg()
json_data = json_get(json_1,text)
json_data["tg_admin"] = id
user = json_data["creator"]
in_ok = easycyber_in(text,json_data)
end_json = json_1.pop(f"{text}")
with open(f'{log_dir}/file/easycyber_tg.json','w',encoding='utf-8') as file:
json.dump(json_1,file)
s["last"] = True
msg = f"[easycyber]已通过投稿用户为{user}关于角色{text}的投稿"
await send_msg(matcher,event,msg)

if s["last"] == "cyber":
json_1 = cyber_in_tg(False,False)
s["last"] = True
json_1 = cyber_in_tg()
json_data = json_get(json_1,text)
logger.debug(json_data)
json_data["tg_admin"] = id
user = json_data["creator"]
in_ok = cyber_in(text,json_data)
end_json = json_1.pop(f"{text}")
with open(f'{log_dir}/file/cyber_tg.json','w',encoding='utf-8') as file:
json.dump(json_1,file)
s["last"] = True
msg = f"[cyber]已通过投稿用户为{user}关于角色{text}的投稿"
msg = f"[cyber]已通过投稿用户为{user}关于角色{text}的投稿"
await send_msg(matcher,event,msg)

if s["last"] == "拒绝":
msg = "请输入要拒绝的预设名称,如果不知道建议先get下列表"
if text == "easycyber":
s["last"] == "badeasyber"
s["last"] = "badeasyber"
await send_msg_reject(matcher,event,msg)
elif text == "cyber":
s["last"] == "badcyber"
s["last"] = "badcyber"
await send_msg_reject(matcher,event,msg)

if s["last"] == "badeasyber":
s["last"] = True
json_1 = easycyber_in_tg(False,False)
json_1 = easycyber_in_tg()
json_data = json_get(json_1,text)
user = json_data["creator"]
end_json = json_1.pop(f"{text}")
Expand All @@ -978,7 +983,7 @@ async def _(matcher: Matcher, bot:Bot, event: MessageEvent, s: T_State):

if s["last"] == "badcyber":
s["last"] = True
json_1 = cyber_in_tg(False,False)
json_1 = cyber_in_tg()
json_data = json_get(json_1,text)
user = json_data["creator"]
end_json = json_1.pop(f"{text}")
Expand Down
30 changes: 15 additions & 15 deletions nonebot_plugin_hx_yinying/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def model_got(msg) -> str:
"""
进行一个模型的切换!
"""
back = "yinyingllm-v2"
back = "yinyingllm-v4"
if msg == "1" or msg == "yinyingllm-v1" or msg == "yinyingllmv1":
back = "yinyingllm-v1"
elif msg == "2" or msg == "yinyingllm-v2" or msg == "yinyingllmv2":
back = "yinyingllm-v2"
elif msg == "3" or msg == "yinyingllm-v3" or msg == "yinyingllmv3":
elif msg == "2" or msg == "yinyingllm-v3" or msg == "yinyingllmv3":
back = "yinyingllm-v3"
elif msg == "3" or msg == "yinyingllm-v4" or msg == "yinyingllmv4":
back = "yinyingllm-v4"
elif msg == "4" or msg == "cyberfurry-001" or msg == "cyberfurry001" or msg == "cyberfurry1":
back = "cyberfurry-001"
elif msg == "5" or msg == "easycyberfurry-001" or msg == "easycyberfurry001" or msg == "easycyberfurry1":
Expand Down Expand Up @@ -288,7 +288,7 @@ def check_update():
logger.warning(f"[Hx_YinYing]:你可能需要重新启动nonebot来完成插件的重载")

#载入本地保存的easycyber预设(一些情况下失败时不会清空,请找到专业人员修复)
def easycyber_in(cybernick,json_1) -> str:
def easycyber_in(cybernick=False,json_1=False) -> str:
"""
载入本地保存的easycyber预设(一些情况下失败时不会清空,请找到专业人员修复)
"""
Expand Down Expand Up @@ -363,7 +363,7 @@ def easycyber_in(cybernick,json_1) -> str:
return back

#载入本地投稿的easycyber预设(载入失败会被清空
def easycyber_in_tg(cybernick,json_1) -> str:
def easycyber_in_tg(cybernick=False,json_1=False) -> str:
"""
载入本地投稿的easycyber预设(载入失败会被清空
"""
Expand Down Expand Up @@ -433,7 +433,7 @@ def easycyber_in_tg(cybernick,json_1) -> str:
return back

#载入本地保存的cyber预设(一些情况下失败时不会清空,请找到专业人员修复)
def cyber_in(cybernick,json_1) -> str:
def cyber_in(cybernick=False,json_1=False) -> str:
"""
载入本地保存的cyber预设(一些情况下失败时不会清空,请找到专业人员修复)
"""
Expand Down Expand Up @@ -502,7 +502,7 @@ def cyber_in(cybernick,json_1) -> str:
return back

#载入本地投稿的cyber预设(载入失败会被清空
def cyber_in_tg(cybernick,json_1) -> str:
def cyber_in_tg(cybernick=False,json_1=False) -> str:
"""
载入本地投稿的cyber预设(载入失败会被清空
"""
Expand Down Expand Up @@ -615,7 +615,7 @@ def config_in_global() -> str:
return back

#载入群聊本地配置
def config_in_group(groupid) -> str:
def config_in_group(groupid=False) -> str:
"""
载入群组本地配置,失败会重置
"""
Expand Down Expand Up @@ -658,14 +658,14 @@ def config_in_group(groupid) -> str:
return back

#载入个人本地配置
def config_in_user(id,nick) -> str:
def config_in_user(id=False,nick=False) -> str:
"""
载入个人本地配置,失败会重置
"""
dt = time.time()
t = int(dt)
id_package = {}
id_package['character'] = f"我是一只可爱的毛毛龙嗷呜"
id_package['character'] = f"一只可爱的毛毛龙"
id_package['character_in'] = True
id_package['easycharacter_in'] = True
id_package['private_model'] = "yinyingllm-v2"
Expand Down Expand Up @@ -1364,16 +1364,16 @@ def process_model(model=None, id_config=None, group_config=None, id=None, nick=N
packages_data['variables'] = allvariables
packages_data['chatId'] = f'{hx_config.yinying_appid}-{id}-{times}-{model}'
packages_data['message'] = text
elif model == "yinyingllm-v2" or model == "yinyingllm-v1" or model == "yinyingllm-v3":
elif model == "yinyingllm-v4" or model == "yinyingllm-v1" or model == "yinyingllm-v3":
packages_data['chatId'] = f'{hx_config.yinying_appid}-{id}-{times}-{model}'
packages_data['variables'] = allvariables
packages_data['message'] = text
if img:
packages_data['multimodal'] = img
else:
logger.warning(f"找不到{id}配置里的模型!将使用默认模型llm2")
packages_data['model'] = 'yinyingllm-v2'
packages_data['chatId'] = f'{hx_config.yinying_appid}-{id}-{times}-yinyingllm-v2'
logger.warning(f"找不到{id}配置里的模型!将使用默认模型llm4")
packages_data['model'] = 'yinyingllm-v4'
packages_data['chatId'] = f'{hx_config.yinying_appid}-{id}-{times}-yinyingllm-v4'
packages_data['message'] = text
packages_data['variables'] = allvariables
if img:
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_hx_yinying/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Config(BaseModel):
# 插件版本号勿动!!!!
hx_version: Optional[str] = "1.3.13"
hx_version: Optional[str] = "1.3.14"
# 秩乱v你的appid
yinying_appid: Optional[str] = None
#自定义命令头,默认为hx chat yinying
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_hx_yinying/image_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def image_upload(url:str)->str:

async def image_check(url:str)->str:
img0 = await image_upload(url)
if hx_config.image_check_appid == None or hx_config.image_check_token == None:
if hx_config.image_check_appid == None or hx_config.image_check_token == None or hx_config.image_check_token == "":
logger.warning("[Hx]未配置图像检测,若因图像违规导致被封开发者id,插件开发者概不负责!!!")
return img0
logger.debug("[Hx]尝试检查图片【爱来自阿里】")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="nonebot-plugin-hx-yinying",
version="1.3.13",
version="1.3.14",
author="Huan Xin",
author_email="mc.xiaolang@foxmail.com",
description="chat with yinying",
Expand Down

0 comments on commit 434e056

Please sign in to comment.