Skip to content

Commit

Permalink
Merge pull request #82 from Isaaczhr/main
Browse files Browse the repository at this point in the history
fix: 更新 NapCat 时使用函数错误
  • Loading branch information
Isaaczhr authored Feb 18, 2025
2 parents af5697a + 5caab8a commit 687f04e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ncatbot/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
OFFICIAL_REQUEST_EVENT,
)
from ncatbot.utils.logger import get_log
from ncatbot.utils.napcat_helper import download_napcat, download_napcat_linux
from ncatbot.utils.napcat_helper import download_napcat

_log = get_log()

Expand Down Expand Up @@ -106,11 +106,24 @@ async def run_async(self):
await self.plugin_sys.load_plugin(self.api)
await websocket_server.ws_connect()

def run(self, reload=False):
if reload:
def run(self, reload=False, debug=False):
"""
启动 Bot 客户端
Args:
reload: 是否同时启动 NapCat , 默认为 False
debug: 是否开启调试模式, 默认为 False, 用户不应该修改此参数
Returns:
None
"""
if not debug:
# 检查版本和安装方式
version_ok = check_version()
if not version_ok:
exit(0)

if reload:
try:
asyncio.run(self.run_async())
except KeyboardInterrupt:
Expand Down Expand Up @@ -148,7 +161,7 @@ def run(self, reload=False):
github_version = get_version(get_proxy_url())
if version != github_version:
_log.info(f"发现新版本: {github_version}")
if not download_napcat_linux("update"):
if not download_napcat("update", base_path):
_log.info(f"跳过 napcat {version} 更新")
else:
_log.info("当前 napcat 已是最新版本")
Expand Down Expand Up @@ -260,10 +273,7 @@ def run(self, reload=False):
exit(0)

_log.info("连接 napcat websocket 服务器成功!")
version_ok = check_version()

if not version_ok:
exit(0)
try:
asyncio.run(self.run_async())
except KeyboardInterrupt:
Expand Down

0 comments on commit 687f04e

Please sign in to comment.