Skip to content

Commit ce40c8c

Browse files
committed
refactor: kook适配器上传文件失败时,会抛出错误
1 parent e27a3ad commit ce40c8c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

astrbot/core/platform/sources/kook/kook_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,20 @@ async def upload_asset(self, file_url: str | None) -> str:
407407
if resp.status == 200:
408408
result: dict = await resp.json()
409409
if result.get("code") == 0:
410-
logger.info("[KOOK] 发送文件消息成功")
410+
logger.info("[KOOK] 上传文件到kook服务器成功")
411411
remote_url = result["data"]["url"]
412412
logger.debug(f"[KOOK] 文件远端URL: {remote_url}")
413413
return remote_url
414414
else:
415-
logger.error(f"[KOOK] 发送文件消息失败: {result}")
415+
raise RuntimeError(f"上传文件到kook服务器失败: {result}")
416416
else:
417-
logger.error(f"[KOOK] 发送文件消息HTTP错误: {resp.status}")
417+
raise RuntimeError(
418+
f"上传文件到kook服务器 HTTP错误: {resp.status} , {await resp.text()}"
419+
)
420+
except RuntimeError:
421+
raise
418422
except Exception as e:
419-
logger.error(f"[KOOK] 发送文件消息异常: {e}")
423+
raise RuntimeError(f"上传文件到kook服务器异常: {e}") from e
420424

421425
return ""
422426

0 commit comments

Comments
 (0)