mcping module
Submodules
mcping.exceptions module
Exceptions for mcping
- exception mcping.exceptions.InvalidResponseError
Bases:
MCPingExceptionFor invalid responses from server, eg. malformed response packet or invalid JSON in status
- exception mcping.exceptions.MCPingException
Bases:
ExceptionBase exception for all other mcping exceptions
- exception mcping.exceptions.ServerTimeoutError
Bases:
MCPingExceptionFor if the server fails to respond in time
Module contents
Get statuses from Minecraft servers
- class mcping.AsyncPinger(connection: TCPAsyncSocketConnection, address: Address, version: int = 47, ping_token: Optional[int] = None)
Bases:
AsyncServerPingerAn async server pinger that returns the parsed status reponse without modification
- async read_status()
- class mcping.Pinger(connection: TCPSocketConnection, address: Address, version: int = 47, ping_token: Optional[int] = None)
Bases:
ServerPingerA server pinger that returns the parsed status reponse without modification
- read_status()
- async mcping.async_status(ip: str, port: int = 25565, timeout: float = 5)
Async function to get a server’s status
- Parameters
ip (str) – The server’s IP
port (int, optional) – The server’s port. Defaults to 25565.
timeout (float, optional) – The time to wait for the server to respond. Defaults to 5.
- Raises
TimeoutError – If the server took too long to respond
InvalidResponseError – If the server gave an invalid response
- Returns
The parsed status response
- Return type
dict
- mcping.status(ip: str, port: int = 25565, timeout: float = 5)
Function to get a server’s status
- Parameters
ip (str) – The server’s IP
port (int, optional) – The server’s port. Defaults to 25565.
timeout (float, optional) – The time to wait for the server to respond. Defaults to 5.
- Raises
TimeoutError – If the server took too long to respond
InvalidResponseError – If the server gave an invalid response
- Returns
The parsed status response
- Return type
dict