Skip to content

Commit

Permalink
采用新的启动脚本启动新版NapCat
Browse files Browse the repository at this point in the history
  • Loading branch information
MetaLe0 committed Aug 2, 2024
1 parent 9184d8b commit edfb6e9
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 29 deletions.
1 change: 1 addition & 0 deletions OlivOS/adapter/onebotV11/flaskServerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'napcat',
'napcat_hide',
'napcat_show',
'napcat_show_new',
'napcat_show_old'
]

Expand Down
1 change: 1 addition & 0 deletions OlivOS/core/core/messageAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'napcat': 'old_string',
'napcat_hide': 'old_string',
'napcat_show': 'old_string',
'napcat_show_new': 'old_string',
'napcat_show_old': 'old_string'
}
},
Expand Down
81 changes: 54 additions & 27 deletions OlivOS/libBooter/libNapCatEXEModelAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'napcat',
'napcat_hide',
'napcat_show',
'napcat_show_new',
'napcat_show_old'
]

Expand All @@ -62,11 +63,19 @@ def startNapCatLibExeModel(
OlivOS.updateAPI.checkResouceFile(
logger_proc=Proc_dict[basic_conf_models_this['logger_proc']],
resouce_api=resourceUrlPath,
resouce_name='NapCat-QQ-Win-9.9.11-24568', # resouce_name='NapCat-QQ-Win-9.9.12-26000',
resouce_name='NapCat-QQ-Win-9.9.11-24568',
filePath='./lib/NapCat.zip',
filePathUpdate='./lib/NapCat.zip.tmp',
filePathFORCESKIP='./lib/FORCESKIP'
)
OlivOS.updateAPI.checkResouceFile(
logger_proc=Proc_dict[basic_conf_models_this['logger_proc']],
resouce_api=resourceUrlPath,
resouce_name='NapCat-QQ-Win-9.9.12-26000',
filePath='./lib/NapCatNew.zip',
filePathUpdate='./lib/NapCat.zip.tmp',
filePathFORCESKIP='./lib/FORCESKIP'
)
for bot_info_key in plugin_bot_info_dict:
if plugin_bot_info_dict[bot_info_key].platform['model'] in gCheckList:
tmp_Proc_name = basic_conf_models_this['name'] + '=' + bot_info_key
Expand Down Expand Up @@ -126,10 +135,16 @@ def run(self):
releaseDir('./conf/napcat')
releaseDir(f"./conf/napcat/{self.Proc_data['bot_info_dict'].hash}")
releaseDir(f"./conf/napcat/{self.Proc_data['bot_info_dict'].hash}/config")
unzip('./lib/NapCat.zip', f"./conf/napcat/{self.Proc_data['bot_info_dict'].hash}")
if self.Proc_data['bot_info_dict'].platform['model'] in [
'napcat_show_new'
]:
unzip('./lib/NapCatNew.zip', f"./conf/napcat/{self.Proc_data['bot_info_dict'].hash}")
else:
unzip('./lib/NapCat.zip', f"./conf/napcat/{self.Proc_data['bot_info_dict'].hash}")
napcatTypeConfig(self.Proc_data['bot_info_dict'], self.Proc_config['target_proc']).setConfig()
if self.Proc_data['bot_info_dict'].platform['model'] in [
'napcat',
'napcat_show_new',
'napcat_show'
]:
self.log(2, OlivOS.L10NAPI.getTrans(
Expand All @@ -147,31 +162,43 @@ def run(self):
args=(),
daemon=self.deamon
).start()
tmp_env = dict(os.environ)
model_Proc = subprocess.Popen(
f".\\napcat-utf8.bat -q {self.Proc_data['bot_info_dict'].id}",
cwd=f".\\conf\\napcat\\{self.Proc_data['bot_info_dict'].hash}",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=tmp_env
)
self.Proc_data['model_Proc'] = model_Proc
threading.Thread(
target=self.check_stdin,
args=(model_Proc,),
daemon=self.deamon
).start()
self.get_model_stdout(model_Proc)
# model_Proc.communicate(timeout = None)
self.log(3, OlivOS.L10NAPI.getTrans(
'OlivOS libNapCatEXEModel server [{0}] will retry in 10s...',
[self.Proc_name], modelName
))
self.Proc_data['model_Proc'] = None
time.sleep(8)
if self.Proc_data['bot_info_dict'].platform['model'] in [
'napcat_show_new'
]:
tmp_env = dict(os.environ)
subprocess.call(
'start powershell .\\BootWay05.ps1',
shell=True,
cwd='.\\conf\\napcat\\' + self.Proc_data['bot_info_dict'].hash,
env=tmp_env
)
self.flag_run = False
else:
tmp_env = dict(os.environ)
model_Proc = subprocess.Popen(
f".\\napcat-utf8.bat -q {self.Proc_data['bot_info_dict'].id}",
cwd=f".\\conf\\napcat\\{self.Proc_data['bot_info_dict'].hash}",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=tmp_env
)
self.Proc_data['model_Proc'] = model_Proc
threading.Thread(
target=self.check_stdin,
args=(model_Proc,),
daemon=self.deamon
).start()
self.get_model_stdout(model_Proc)
# model_Proc.communicate(timeout = None)
self.log(3, OlivOS.L10NAPI.getTrans(
'OlivOS libNapCatEXEModel server [{0}] will retry in 10s...',
[self.Proc_name], modelName
))
self.Proc_data['model_Proc'] = None
time.sleep(8)
elif self.Proc_data['bot_info_dict'].platform['model'] in [
'napcat_show_old'
]:
Expand Down
12 changes: 10 additions & 2 deletions OlivOS/nativeGUI/multiLoginUIAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'edit_root_Combobox_dict': {
'type_list': [
'QQ/NapCat/默认',
'QQ/NapCat/9.9.11',
'QQ/OPQ/默认',
'QQ/GoCq/安卓平板',
'QQ/GoCq/安卓手机',
Expand Down Expand Up @@ -429,7 +430,8 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'QQ/OPQ/默认': '简单对接OPQ,使用闭源框架有账号安全风险,OlivOS不对此负责',
'QQ/OPQ/指定端口': '简单对接OPQ,使用闭源框架有账号安全风险,OlivOS不对此负责',
'QQ/OPQ/指定端口/旧': '简单对接OPQ,使用闭源框架有账号安全风险,OlivOS不对此负责',
'QQ/NapCat/默认': '使用本方法需要已经安装较新版本QQ',
'QQ/NapCat/默认': '需要已经安装不低于9.9.12版本QQ',
'QQ/NapCat/9.9.11': '需要已经安装不高于9.9.11版本QQ',
'QQ/NapCat/旧': '使用本方法需要已经安装较新版本QQ'
},
'type_clear_note_list': {
Expand All @@ -448,6 +450,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'QQ/OPQ/指定端口': './conf/OPQBot/{bothash}',
'QQ/OPQ/指定端口/旧': './conf/OPQBot/{bothash}',
'QQ/NapCat/默认': './conf/napcat/{bothash}',
'QQ/NapCat/9.9.11': './conf/napcat/{bothash}',
'QQ/NapCat/旧': './conf/napcat/{bothash}'
},
'type_extend_note_list': {
Expand Down Expand Up @@ -542,7 +545,11 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'TOKEN': 'edit_root_Entry_Server_access_token',
}
],
'QQ/NapCat/默认': ['qq', 'onebot', 'napcat_show', 'True', 'post', {
'QQ/NapCat/默认': ['qq', 'onebot', 'napcat_show_new', 'True', 'post', {
'QQ号': 'edit_root_Entry_ID',
}
],
'QQ/NapCat/9.9.11': ['qq', 'onebot', 'napcat_show', 'True', 'post', {
'QQ号': 'edit_root_Entry_ID',
}
],
Expand Down Expand Up @@ -889,6 +896,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'napcat',
#'napcat_hide',
'napcat_show',
'napcat_show_new',
'napcat_show_old'
]
},
Expand Down

0 comments on commit edfb6e9

Please sign in to comment.