fix: !version 命令获取最新版本失败时导致命令失败

This commit is contained in:
RockChinQ 2024-02-19 21:47:51 +08:00
parent 0bf85fb644
commit 082731ba32
2 changed files with 1 additions and 28 deletions

View File

@ -16,7 +16,7 @@ class VersionCommand(operator.CommandOperator):
self,
context: entities.ExecuteContext
) -> typing.AsyncGenerator[entities.CommandReturn, None]:
reply_str = f"当前版本: \n{await self.ap.ver_mgr.get_current_version_info()}"
reply_str = f"当前版本: \n{self.ap.ver_mgr.get_current_version()}"
try:
if await self.ap.ver_mgr.is_new_version_available():

View File

@ -28,36 +28,9 @@ class VersionManager:
self
) -> str:
current_tag = constants.semantic_version
if os.path.exists("current_tag"):
with open("current_tag", "r") as f:
current_tag = f.read()
return current_tag
async def get_current_version_info(
self
) -> str:
"""获取当前版本信息"""
rls_list = await self.get_release_list()
current_tag = self.get_current_version()
for rls in rls_list:
if rls['tag_name'] == current_tag:
return rls['name'] + "\n" + rls['body']
return "未知版本"
async def get_release_list(self) -> list:
"""获取发行列表"""
rls_list_resp = requests.get(
url="https://api.github.com/repos/RockChinQ/QChatGPT/releases",
proxies=self.ap.proxy_mgr.get_forward_proxies(),
timeout=5
)
rls_list = rls_list_resp.json()
return rls_list
async def update_all(self):
"""检查更新并下载源码"""
start_time = time.time()