diff --git a/Cargo.lock b/Cargo.lock index db0e025..ddee05b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "kon" -version = "0.2.6" +version = "0.2.7" dependencies = [ "cargo_toml", "gamedig", @@ -1799,9 +1799,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -2117,9 +2117,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokenservice-client" -version = "0.1.0" +version = "0.2.0" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" -checksum = "7da0d635427394e32f228f3c0c7642e1ffd3fe1f668739b1435fd737bb9f58e6" +checksum = "ce6d723554b87f8068463a7aae14ed604e2804a8a0827d251d7ac08850bac18e" dependencies = [ "reqwest 0.12.2", "serde", diff --git a/Cargo.toml b/Cargo.toml index 8e2bd08..93b8896 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ [package] name = "kon" -version = "0.2.6" -rust-version = "1.75" +version = "0.2.7" edition = "2021" [dependencies] @@ -13,7 +12,7 @@ reqwest = { version = "0.12.2", features = ["json"] } serde = "1.0.197" serde_json = "1.0.115" sysinfo = "0.30.7" -tokenservice-client = { version = "0.1.0", registry = "gitea" } +tokenservice-client = { version = "0.2.0", registry = "gitea" } tokio = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] } tokio-postgres = "0.7.10" uptime_lib = "0.3.0" diff --git a/docker-compose.yml b/docker-compose.yml index 3de970a..d898278 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: bot: container_name: kon diff --git a/run.sh b/run.sh index 97f9808..2806c3a 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -export $(grep -v '^#' .env | xargs) && cargo run +export $(grep -v '^#' .env | xargs) && cargo run kon_dev diff --git a/src/commands/status.rs b/src/commands/status.rs index 83a1aac..78ed7e2 100644 --- a/src/commands/status.rs +++ b/src/commands/status.rs @@ -3,24 +3,17 @@ use crate::{ models::gameservers::Gameservers, commands::gameserver::ac_server_name, internals::utils::EMBED_COLOR, - internals::http::HttpClient + internals::http::HttpClient, + internals::utils::token_path }; -use std::{ - collections::HashMap, - env::var -}; +use std::collections::HashMap; use tokio::join; use poise::CreateReply; use poise::serenity_prelude::builder::CreateEmbed; -use once_cell::sync::Lazy; use serde::Deserialize; use serde_json::Value; -static PMS_BASE: Lazy = Lazy::new(|| - var("WG_PMS").expect("Expected a \"WG_PMS\" in the envvar but none was found") -); - #[derive(Deserialize)] struct MinecraftQueryData { motd: Option, @@ -114,8 +107,8 @@ pub async fn status(_: poise::Context<'_, (), Error>) -> Result<(), Error> { /// Retrieve the server statuses from Wargaming #[poise::command(slash_command)] pub async fn wg(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> { - let pms_asia = &PMS_BASE; - let pms_eu = PMS_BASE.replace("asia", "eu"); + let pms_asia = token_path().await.wg_pms; + let pms_eu = pms_asia.replace("asia", "eu"); let embed = CreateEmbed::new().color(EMBED_COLOR); let (servers_asia, servers_eu) = join!(pms_serverstatus(&pms_asia), pms_serverstatus(&pms_eu)); diff --git a/src/internals/tsclient.rs b/src/internals/tsclient.rs index c8d9122..2473441 100644 --- a/src/internals/tsclient.rs +++ b/src/internals/tsclient.rs @@ -6,8 +6,10 @@ pub struct TSClient { impl TSClient { pub fn new() -> Self { + let args: Vec = std::env::args().collect(); + let service = if args.len() > 1 { args[1].as_str() } else { "kon" }; TSClient { - client: TokenService::new("kon") + client: TokenService::new(service) } } pub async fn get(&self) -> Result> {