From e36161ce5ac6299514c13ce964e9f511eb00eac3 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Fri, 25 Nov 2022 18:59:25 +0200 Subject: [PATCH] Edited README.md --- README.md | 41 ++++++++++++++++++++++++++++---- examples/master_querant.rs | 48 +++++++++++++++++++------------------- examples/minecraft.rs | 4 ++-- examples/tf2.rs | 4 ++-- 4 files changed, 64 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index a7aa841..b0fb664 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,54 @@ MSRV is `1.58.1` and the code is cross-platform. To see the supported (or the planned to support) games/services/protocols, see [GAMES](GAMES.md), [SERVICES](SERVICES.md) and [PROTOCOLS](PROTOCOLS.md) respectively. ## Usage -Just pick a game/service/protocol, provide the ip and the port (can be optional) then query on it. +Just pick a game/service/protocol, provide the ip and the port (can be optional) then query on it. +Team Fortress 2 query example: ```rust use gamedig::games::tf2; fn main() { - let response = tf2::query("91.216.250.10", None); //or Some(27015), None is the default protocol port + let response = tf2::query("localhost", None); //or Some(27015), None is the default protocol port match response { Err(error) => println!("Couldn't query, error: {error}"), - Ok(r) => println!("{:?}", r) + Ok(r) => println!("{:#?}", r) } } ``` +Response: +```json5 +{ + protocol: 17, + name: "Team Fortress 2 Dedicated Server!", + map: "ctf_turbine", + game: "tf2", + players: 0, + players_details: [], + max_players: 69, + bots: 0, + server_type: Dedicated, + has_password: false, + vac_secured: true, + version: "7638371", + port: Some(27015), + steam_id: Some(69753253289735296), + tv_port: None, + tv_name: None, + keywords: Some("alltalk,arena,nocrits"), + rules: [ + ServerRule { + name: "mp_autoteambalance", + value: "1", + } + //.... + ] +} +``` + To see more examples, see the [examples](examples) folder. ## Documentation The documentation is available at [docs.rs](https://docs.rs/gamedig/latest/gamedig/). -Curious about the history and what changed between versions? you can see just that in the [CHANGELOG](CHANGELOG.md) file. +Curious about the history and what changed between versions? Check out the [CHANGELOG](CHANGELOG.md) file. ## Contributing -If you want see your favorite game/service being supported here, open an issue, and I'll prioritize it! (or do a pull request if you want to implement it yourself) +If you want see your favorite game/service being supported here, open an issue, and I'll prioritize it (or do a pull request if you want to implement it yourself)! diff --git a/examples/master_querant.rs b/examples/master_querant.rs index a050a23..0992fa1 100644 --- a/examples/master_querant.rs +++ b/examples/master_querant.rs @@ -26,30 +26,30 @@ fn main() -> GDResult<()> { }; match args[1].as_str() { - "aliens" => println!("{:?}", aliens::query(ip, port)?), - "asrd" => println!("{:?}", asrd::query(ip, port)?), - "csgo" => println!("{:?}", csgo::query(ip, port)?), - "css" => println!("{:?}", css::query(ip, port)?), - "dods" => println!("{:?}", dods::query(ip, port)?), - "gm" => println!("{:?}", gm::query(ip, port)?), - "hl2dm" => println!("{:?}", hl2dm::query(ip, port)?), - "tf2" => println!("{:?}", tf2::query(ip, port)?), - "insmic" => println!("{:?}", insmic::query(ip, port)?), - "ins" => println!("{:?}", ins::query(ip, port)?), - "inss" => println!("{:?}", inss::query(ip, port)?), - "l4d" => println!("{:?}", l4d::query(ip, port)?), - "l4d2" => println!("{:?}", l4d2::query(ip, port)?), - "ts" => println!("{:?}", ts::query(ip, port)?), - "cscz" => println!("{:?}", cscz::query(ip, port)?), - "dod" => println!("{:?}", dod::query(ip, port)?), - "mc" => println!("{:?}", mc::query(ip, port)?), - "mc_java" => println!("{:?}", mc::query_specific(Server::Java, ip, port)?), - "mc_legacy_vb1_8" => println!("{:?}", mc::query_specific(Server::Legacy(LegacyGroup::VB1_8), ip, port)?), - "mc_legacy_v1_4" => println!("{:?}", mc::query_specific(Server::Legacy(LegacyGroup::V1_4), ip, port)?), - "mc_legacy_v1_6" => println!("{:?}", mc::query_specific(Server::Legacy(LegacyGroup::V1_6), ip, port)?), - "_src" => println!("{:?}", valve::query(ip, 27015, App::Source(None), None, None)?), - "_gld" => println!("{:?}", valve::query(ip, 27015, App::GoldSrc(false), None, None)?), - "_gld_f" => println!("{:?}", valve::query(ip, 27015, App::GoldSrc(true), None, None)?), + "aliens" => println!("{:#?}", aliens::query(ip, port)?), + "asrd" => println!("{:#?}", asrd::query(ip, port)?), + "csgo" => println!("{:#?}", csgo::query(ip, port)?), + "css" => println!("{:#?}", css::query(ip, port)?), + "dods" => println!("{:#?}", dods::query(ip, port)?), + "gm" => println!("{:#?}", gm::query(ip, port)?), + "hl2dm" => println!("{:#?}", hl2dm::query(ip, port)?), + "tf2" => println!("{:#?}", tf2::query(ip, port)?), + "insmic" => println!("{:#?}", insmic::query(ip, port)?), + "ins" => println!("{:#?}", ins::query(ip, port)?), + "inss" => println!("{:#?}", inss::query(ip, port)?), + "l4d" => println!("{:#?}", l4d::query(ip, port)?), + "l4d2" => println!("{:#?}", l4d2::query(ip, port)?), + "ts" => println!("{:#?}", ts::query(ip, port)?), + "cscz" => println!("{:#?}", cscz::query(ip, port)?), + "dod" => println!("{:#?}", dod::query(ip, port)?), + "mc" => println!("{:#?}", mc::query(ip, port)?), + "mc_java" => println!("{:#?}", mc::query_specific(Server::Java, ip, port)?), + "mc_legacy_vb1_8" => println!("{:#?}", mc::query_specific(Server::Legacy(LegacyGroup::VB1_8), ip, port)?), + "mc_legacy_v1_4" => println!("{:#?}", mc::query_specific(Server::Legacy(LegacyGroup::V1_4), ip, port)?), + "mc_legacy_v1_6" => println!("{:#?}", mc::query_specific(Server::Legacy(LegacyGroup::V1_6), ip, port)?), + "_src" => println!("{:#?}", valve::query(ip, 27015, App::Source(None), None, None)?), + "_gld" => println!("{:#?}", valve::query(ip, 27015, App::GoldSrc(false), None, None)?), + "_gld_f" => println!("{:#?}", valve::query(ip, 27015, App::GoldSrc(true), None, None)?), _ => panic!("Undefined game: {}", args[1]) }; diff --git a/examples/minecraft.rs b/examples/minecraft.rs index 791f958..6b9ec6e 100644 --- a/examples/minecraft.rs +++ b/examples/minecraft.rs @@ -2,9 +2,9 @@ use gamedig::games::mc; fn main() { - let response = mc::query("localhost", None); //or Some(25565), None is the default protocol port (which is 25565) + let response = mc::query("cosminperram.com", Some(26062)); //or Some(25565), None is the default protocol port (which is 25565) match response { Err(error) => println!("Couldn't query, error: {error}"), - Ok(r) => println!("{:?}", r) + Ok(r) => println!("{:#?}", r) } } diff --git a/examples/tf2.rs b/examples/tf2.rs index eb8c70a..e79cb7f 100644 --- a/examples/tf2.rs +++ b/examples/tf2.rs @@ -2,9 +2,9 @@ use gamedig::games::tf2; fn main() { - let response = tf2::query("cosminperram.com", None); //or Some(27015), None is the default protocol port (which is 27015) + let response = tf2::query("localhost", None); //or Some(27015), None is the default protocol port (which is 27015) match response { Err(error) => println!("Couldn't query, error: {error}"), - Ok(r) => println!("{:?}", r) + Ok(r) => println!("{:#?}", r) } }