Use WG_PMS url from TokenService instead
All checks were successful
Build and push container image / build (push) Successful in 10m53s

This commit is contained in:
toast 2024-03-27 09:57:00 +11:00
parent eaadbb69af
commit bd042781a8
6 changed files with 16 additions and 23 deletions

10
Cargo.lock generated
View File

@ -952,7 +952,7 @@ dependencies = [
[[package]] [[package]]
name = "kon" name = "kon"
version = "0.2.6" version = "0.2.7"
dependencies = [ dependencies = [
"cargo_toml", "cargo_toml",
"gamedig", "gamedig",
@ -1799,9 +1799,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.114" version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -2117,9 +2117,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokenservice-client" name = "tokenservice-client"
version = "0.1.0" version = "0.2.0"
source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"
checksum = "7da0d635427394e32f228f3c0c7642e1ffd3fe1f668739b1435fd737bb9f58e6" checksum = "ce6d723554b87f8068463a7aae14ed604e2804a8a0827d251d7ac08850bac18e"
dependencies = [ dependencies = [
"reqwest 0.12.2", "reqwest 0.12.2",
"serde", "serde",

View File

@ -1,7 +1,6 @@
[package] [package]
name = "kon" name = "kon"
version = "0.2.6" version = "0.2.7"
rust-version = "1.75"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
@ -13,7 +12,7 @@ reqwest = { version = "0.12.2", features = ["json"] }
serde = "1.0.197" serde = "1.0.197"
serde_json = "1.0.115" serde_json = "1.0.115"
sysinfo = "0.30.7" 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 = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] }
tokio-postgres = "0.7.10" tokio-postgres = "0.7.10"
uptime_lib = "0.3.0" uptime_lib = "0.3.0"

View File

@ -1,4 +1,3 @@
version: '3.8'
services: services:
bot: bot:
container_name: kon container_name: kon

2
run.sh
View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
export $(grep -v '^#' .env | xargs) && cargo run export $(grep -v '^#' .env | xargs) && cargo run kon_dev

View File

@ -3,24 +3,17 @@ use crate::{
models::gameservers::Gameservers, models::gameservers::Gameservers,
commands::gameserver::ac_server_name, commands::gameserver::ac_server_name,
internals::utils::EMBED_COLOR, internals::utils::EMBED_COLOR,
internals::http::HttpClient internals::http::HttpClient,
internals::utils::token_path
}; };
use std::{ use std::collections::HashMap;
collections::HashMap,
env::var
};
use tokio::join; use tokio::join;
use poise::CreateReply; use poise::CreateReply;
use poise::serenity_prelude::builder::CreateEmbed; use poise::serenity_prelude::builder::CreateEmbed;
use once_cell::sync::Lazy;
use serde::Deserialize; use serde::Deserialize;
use serde_json::Value; use serde_json::Value;
static PMS_BASE: Lazy<String> = Lazy::new(||
var("WG_PMS").expect("Expected a \"WG_PMS\" in the envvar but none was found")
);
#[derive(Deserialize)] #[derive(Deserialize)]
struct MinecraftQueryData { struct MinecraftQueryData {
motd: Option<MinecraftMotd>, motd: Option<MinecraftMotd>,
@ -114,8 +107,8 @@ pub async fn status(_: poise::Context<'_, (), Error>) -> Result<(), Error> {
/// Retrieve the server statuses from Wargaming /// Retrieve the server statuses from Wargaming
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn wg(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> { pub async fn wg(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> {
let pms_asia = &PMS_BASE; let pms_asia = token_path().await.wg_pms;
let pms_eu = PMS_BASE.replace("asia", "eu"); let pms_eu = pms_asia.replace("asia", "eu");
let embed = CreateEmbed::new().color(EMBED_COLOR); let embed = CreateEmbed::new().color(EMBED_COLOR);
let (servers_asia, servers_eu) = join!(pms_serverstatus(&pms_asia), pms_serverstatus(&pms_eu)); let (servers_asia, servers_eu) = join!(pms_serverstatus(&pms_asia), pms_serverstatus(&pms_eu));

View File

@ -6,8 +6,10 @@ pub struct TSClient {
impl TSClient { impl TSClient {
pub fn new() -> Self { pub fn new() -> Self {
let args: Vec<String> = std::env::args().collect();
let service = if args.len() > 1 { args[1].as_str() } else { "kon" };
TSClient { TSClient {
client: TokenService::new("kon") client: TokenService::new(service)
} }
} }
pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> { pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> {