Use WG_PMS url from TokenService instead
All checks were successful
Build and push container image / build (push) Successful in 10m53s
All checks were successful
Build and push container image / build (push) Successful in 10m53s
This commit is contained in:
parent
eaadbb69af
commit
bd042781a8
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -1,4 +1,3 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
bot:
|
||||
container_name: kon
|
||||
|
2
run.sh
2
run.sh
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
export $(grep -v '^#' .env | xargs) && cargo run
|
||||
export $(grep -v '^#' .env | xargs) && cargo run kon_dev
|
||||
|
@ -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<String> = Lazy::new(||
|
||||
var("WG_PMS").expect("Expected a \"WG_PMS\" in the envvar but none was found")
|
||||
);
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct MinecraftQueryData {
|
||||
motd: Option<MinecraftMotd>,
|
||||
@ -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));
|
||||
|
@ -6,8 +6,10 @@ pub struct TSClient {
|
||||
|
||||
impl TSClient {
|
||||
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 {
|
||||
client: TokenService::new("kon")
|
||||
client: TokenService::new(service)
|
||||
}
|
||||
}
|
||||
pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> {
|
||||
|
Loading…
Reference in New Issue
Block a user