Skip to content

Commit

Permalink
🐛 Fix: pydantic v2 URL support (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lgc2333 and pre-commit-ci[bot] authored Feb 16, 2024
1 parent 4f8bc16 commit f36e9c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion nonebot/adapters/onebot/v11/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"):
Expand Down Expand Up @@ -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)))
Expand Down
3 changes: 2 additions & 1 deletion nonebot/adapters/onebot/v12/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit f36e9c5

Please sign in to comment.