diff --git a/nonebot/adapters/onebot/v11/adapter.py b/nonebot/adapters/onebot/v11/adapter.py index 3376b4f7..5e301cd6 100644 --- a/nonebot/adapters/onebot/v11/adapter.py +++ b/nonebot/adapters/onebot/v11/adapter.py @@ -149,7 +149,7 @@ async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any: raise NetworkError(f"WebSocket call api {api} timeout") from None elif isinstance(self.driver, HTTPClientMixin): - api_root = self.onebot_config.onebot_api_roots.get(bot.self_id) + api_root = str(self.onebot_config.onebot_api_roots.get(bot.self_id)) if not api_root: raise ApiNotAvailable elif not api_root.endswith("/"): @@ -298,6 +298,7 @@ def _check_access_token(self, request: Request) -> Optional[Response]: async def _start_forward(self) -> None: for url in self.onebot_config.onebot_ws_urls: + url = str(url) try: ws_url = URL(url) self.tasks.append(asyncio.create_task(self._forward_ws(ws_url))) diff --git a/nonebot/adapters/onebot/v12/adapter.py b/nonebot/adapters/onebot/v12/adapter.py index 50787b8f..42433f3c 100644 --- a/nonebot/adapters/onebot/v12/adapter.py +++ b/nonebot/adapters/onebot/v12/adapter.py @@ -201,7 +201,7 @@ async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any: raise NetworkError(f"WebSocket call api {api} timeout") from None elif isinstance(self.driver, HTTPClientMixin): - api_url = self.onebot_config.onebot_api_roots.get(bot.self_id) + api_url = str(self.onebot_config.onebot_api_roots.get(bot.self_id)) if not api_url: raise ApiNotAvailable @@ -414,6 +414,7 @@ def _check_access_token(self, request: Request) -> Optional[Response]: async def _start_forward(self) -> None: for url in self.onebot_config.onebot_ws_urls: + url = str(url) try: ws_url = URL(url) self.tasks.append(asyncio.create_task(self._forward_ws(ws_url)))