2727plugin_config = get_plugin_config (Config )
2828api_key = plugin_config .osu_api_key
2929refresh_interval = plugin_config .osu_refresh_interval
30+ api_timeout = plugin_config .osu_api_timeout
3031API_URL_MATCH = "https://osu.ppy.sh/api/get_match"
3132API_URL_USER = "https://osu.ppy.sh/api/get_user"
3233API_URL_BEATMAP = "https://osu.ppy.sh/api/get_beatmaps"
@@ -203,7 +204,7 @@ async def get_match_info(room_id: str) -> Dict:
203204 "mp" : room_id
204205 }
205206 try :
206- async with httpx .AsyncClient () as client :
207+ async with httpx .AsyncClient (timeout = api_timeout ) as client :
207208 response = await client .get (API_URL_MATCH , params = params )
208209 logger .debug (f"请求房间 { room_id } 的比赛信息,状态码:{ response .status_code } " )
209210 if response .status_code == 200 :
@@ -228,7 +229,7 @@ async def get_user_info(user_id: str) -> Dict:
228229 "type" : "id"
229230 }
230231 try :
231- async with httpx .AsyncClient () as client :
232+ async with httpx .AsyncClient (timeout = api_timeout ) as client :
232233 response = await client .get (API_URL_USER , params = params )
233234 if response .status_code == 200 :
234235 data = response .json ()
@@ -251,7 +252,7 @@ async def get_beatmap_info(beatmap_id: str) -> Dict:
251252 "limit" : 1
252253 }
253254 try :
254- async with httpx .AsyncClient () as client :
255+ async with httpx .AsyncClient (timeout = api_timeout ) as client :
255256 response = await client .get (API_URL_BEATMAP , params = params )
256257 if response .status_code == 200 :
257258 data = response .json ()
0 commit comments