Pings minecraft server to get their online/offline state. Offers bulk async pinging.
Project description
Minecraft Ping
- Pings asynchronously Minecraft servers
- Only gets their Online/Offline boolean
- Useful to ping a huge list of ips to test for running MC servers.
Sample code / Quickstart
import asyncio
from minecraft_ping import MinecraftPing
async def callback(addr: str, port: int, is_online: bool) -> None:
# Here handle the server, put it in a json file or anything else.
print(addr, port, is_online)
async def main() -> None:
mc_ping: MinecraftPing = MinecraftPing(
timeout=5,
callback=callback
)
is_online: bool = await mc_ping.get_state('mc.hypixel.net', 25565)
print(f'The server is {"online" if is_online else "offline"}.')
servers: set[tuple[str, int]] = {
('mc.hypixel.net', 25565),
('hub.opblocks.com', 25565),
('valheim_is_a_great_game', 123)
}
# Here for every server, the callback function will be called.
await mc_ping.get_state_bulk(servers)
# If no callback function is provided, default is to write a file with all the online servers.
# You can modify the default callback output filepath with the `callback_filepath_out`
# when instantiating MinecraftPing.
if __name__ == '__main__':
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
minecraft_ping-0.0.4.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file minecraft_ping-0.0.4.tar.gz
.
File metadata
- Download URL: minecraft_ping-0.0.4.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 674456e64b2c7bab76b870db66f1b2f7620c8f6391cbd57e5333e85acecf252f |
|
MD5 | 171b217302c8f718f35cd60b6110a455 |
|
BLAKE2b-256 | e685adbb31f60c3948410a9cbed8401d4bb33c983d328d304be87a3c92f8aba9 |
File details
Details for the file minecraft_ping-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: minecraft_ping-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3549f6ba73bdfaec9000d682501689519cb9da79c70d73372262df71e0d314fe |
|
MD5 | c3e916c346eb2a5264a724aca926038c |
|
BLAKE2b-256 | 6b6a6a33748058a68cb3ae37f07e4a56441bc8d193cddc2b5c706b6720f84c47 |