Skip to content

Commit

Permalink
fix(mcstatus): ConnectionRefusedError
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka13514 committed Aug 4, 2023
1 parent 17858c2 commit 48617fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion atribot/plugins/nonebot_plugin_mcstatus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def _():
players = (status.players.online if server.server_type
== "JE" else status.players_online)

except (socket.timeout, socket.gaierror):
except (ConnectionRefusedError, socket.timeout, socket.gaierror):
retry = server.retry + 1
if retry >= 3:
online = False
Expand Down
4 changes: 4 additions & 0 deletions atribot/plugins/nonebot_plugin_mcstatus/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ async def lookup_server(server: Server) -> str:
status = await asyncio.to_thread(
BedrockServer.lookup(server.address).status)
return put_status(server, status)
except ConnectionRefusedError:
return f"{server.name}服务器拒绝连接"
except socket.timeout:
return f"{server.name}服务器获取状态超时"
except socket.gaierror:
Expand Down Expand Up @@ -115,6 +117,8 @@ async def add(cls, args: Namespace) -> str:
players = BedrockServer.lookup(
args.address).status().players_online
server_type = 'BE'
except ConnectionRefusedError:
return "服务器拒绝连接"
except socket.gaierror:
return "域名解析失败"
except socket.timeout:
Expand Down

0 comments on commit 48617fb

Please sign in to comment.