Skip to content

Commit

Permalink
V2.9.5 some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ValgulNecron committed Jul 9, 2024
1 parent 0e05701 commit a994e6e
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 120 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tokio = { version = "1.38.0", features = ["full"] }
sqlx = { version = "0.7.4", features = ["sqlite", "runtime-tokio-native-tls", "postgres"] }
rand = "0.9.0-alpha.1"
chrono = "0.4.38"
uuid = { version = "1.9.1", features = ["v4"] }
uuid = { version = "1.10.0", features = ["v4"] }
image = "0.25.1"
base64 = "0.22.1"
tracing = { version = "0.1.40" }
Expand All @@ -32,24 +32,24 @@ serde_with = { version = "3.8.3", features = ["macros"] }
rust-fuzzy-search = "0.1.1"
palette = "0.7.6"
tracing-appender = "0.2.3"
tonic = { version = "0.11.0", features = ["tls"] }
prost = "0.12.6"
tonic-reflection = "0.11.0"
sysinfo = "0.30.12"
tonic = { version = "0.12.0", features = ["tls"] }
prost = "0.13.1"
tonic-reflection = "0.12.0"
sysinfo = "0.30.13"
rayon = "1.10.0"
os_info = "3.8.2"
rcgen = "0.13.1"
markdown_converter = "0.3.4"
futures = "0.3.30"
rapidfuzz = "0.5.0"
cynic = { version = "3.7.3", features = ["reqwest", "http-reqwest", "serde_json"] }
moka = { version = "0.12.7", features = ["future"] }
moka = { version = "0.12.8", features = ["future"] }
toml = "0.8.14"
num-bigint = "0.4.6"
text-to-png = "0.2.0"

[build-dependencies]
tonic-build = "0.11.0"
tonic-build = "0.12.0"
cynic-codegen = { version = "3.7.3" }

[profile.dev]
Expand Down
5 changes: 0 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.file_descriptor_set_path(out_dir.join("command_descriptor.bin"))
.compile(&["proto/command.proto"], &["proto"])?;

tonic_build::configure()
.protoc_arg("--experimental_allow_proto3_optional")
.file_descriptor_set_path(out_dir.join("federation_descriptor.bin"))
.compile(&["proto/federation.proto"], &["proto"])?;

cynic_codegen::register_schema("anilist")
.from_sdl_file("schemas/anilist.graphql")?
.as_default()?;
Expand Down
28 changes: 24 additions & 4 deletions json/message/game/steam_game_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"field7": "Categories",
"free": "Free",
"coming_soon": "Coming soon",
"tba": "TBA"
"tba": "TBA",
"win": "Windows",
"mac": "Mac",
"linux": "Linux",
"website": "Website",
"required_age": "Required age"
},
"fr": {
"field1": "Prix",
Expand All @@ -22,7 +27,12 @@
"field8": "Avis",
"free": "Gratuit",
"coming_soon": "Bientôt disponible",
"tba": "À annoncer"
"tba": "À annoncer",
"win": "Windows",
"mac": "Mac",
"linux": "Linux",
"website": "Site web",
"required_age": "Âge requis"
},
"de": {
"field1": "Preis",
Expand All @@ -35,7 +45,12 @@
"field8": "Bewertungen",
"free": "Kostenlos",
"coming_soon": "Demnächst verfügbar",
"tba": "TBA"
"tba": "TBA",
"win": "Windows",
"mac": "Mac",
"linux": "Linux",
"website": "Webseite",
"required_age": "Erforderliches Alter"
},
"jp": {
"field1": "価格",
Expand All @@ -48,6 +63,11 @@
"field8": "レビュー",
"free": "無料",
"coming_soon": "近日公開",
"tba": "TBA"
"tba": "TBA",
"win": "Windows",
"mac": "Mac",
"linux": "Linux",
"website": "ウェブサイト",
"required_age": "必要年齢"
}
}
59 changes: 52 additions & 7 deletions src/command/run/steam/steam_game_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::helper::get_option::subcommand::get_option_map_string_subcommand;
use crate::structure::message::game::steam_game_info::{
load_localization_steam_game_info, SteamGameInfoLocalised,
};
use crate::structure::run::game::steam_game::SteamGameWrapper;
use crate::structure::run::game::steam_game::{Platforms, SteamGameWrapper};

/// Executes the command to retrieve and display a Steam game's information.
///
Expand Down Expand Up @@ -118,11 +118,14 @@ async fn send_embed(
)
} else {
match game.price_overview {
Some(price) => (
steam_game_info_localised.field1,
convert_steam_to_discord_flavored_markdown(price.final_formatted.unwrap()),
true,
),
Some(price) => {
let price = format!("{} {}", price.final_formatted.unwrap_or_default(), price.discount_percent.unwrap_or_default());
(
steam_game_info_localised.field1,
convert_steam_to_discord_flavored_markdown(price),
true,
)
},
None => (
steam_game_info_localised.field1,
steam_game_info_localised.tba,
Expand All @@ -131,6 +134,30 @@ async fn send_embed(
}
};
fields.push(field1);
let platforms = match game.platforms {
Some(platforms) => platforms,
_ => {
Platforms {
windows: None,
mac: None,
linux: None,
}
}};

if let Some(website) = game.website {
fields.push((
steam_game_info_localised.website,
convert_steam_to_discord_flavored_markdown(website),
true,
));
}
if let Some(required_age) = game.required_age {
fields.push((
steam_game_info_localised.required_age,
required_age.to_string(),
true,
));
}

// Determine the release date field based on whether the game is coming soon or not
let field2 = if game.release_date.clone().unwrap().coming_soon {
Expand Down Expand Up @@ -187,9 +214,27 @@ async fn send_embed(
fields.push((
steam_game_info_localised.field6,
convert_steam_to_discord_flavored_markdown(game_lang),
false,
true,
))
}
let win = platforms.windows.unwrap_or(false);
let mac = platforms.mac.unwrap_or(false);
let linux = platforms.linux.unwrap_or(false);
fields.push((
steam_game_info_localised.win,
win.to_string(),
true,
));
fields.push((
steam_game_info_localised.mac,
mac.to_string(),
true,
));
fields.push((
steam_game_info_localised.linux,
linux.to_string(),
true,
));

// Add the categories field if it exists
if let Some(categories) = game.categories {
Expand Down
2 changes: 1 addition & 1 deletion src/grpc_server/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn grpc_server_launcher(
};

// Configure the reflection service and register the file descriptor set for the shard service
let mut reflection = tonic_reflection::server::Builder::configure()
let reflection = tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(service::shard::proto::SHARD_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(service::info::proto::INFO_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(service::command::proto::COMMAND_FILE_DESCRIPTOR_SET);
Expand Down
5 changes: 5 additions & 0 deletions src/structure/message/game/steam_game_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub struct SteamGameInfoLocalised {
pub free: String,
pub coming_soon: String,
pub tba: String,
pub win: String,
pub mac: String,
pub linux: String,
pub website: String,
pub required_age: String,
}

/// `load_localization_steam_game_info` is an asynchronous function that loads the localized data for a Steam game.
Expand Down
96 changes: 0 additions & 96 deletions src/structure/run/game/steam_game.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use regex::Regex;
use rust_fuzzy_search::fuzzy_search_sorted;
use serde::{Deserialize, Serialize};
use serde_with::formats::PreferOne;
use serde_with::serde_as;
use serde_with::OneOrMany;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::RwLock;
Expand All @@ -29,83 +27,25 @@ pub struct Data {
pub steam_appid: Option<u32>,
pub required_age: Option<u32>,
pub is_free: Option<bool>,
pub detailed_description: Option<String>,
pub about_the_game: Option<String>,
pub short_description: Option<String>,
pub supported_languages: Option<String>,
pub reviews: Option<String>,
pub header_image: Option<String>,
pub capsule_image: Option<String>,
pub capsule_imagev5: Option<String>,
pub website: Option<String>,
#[serde_as(deserialize_as = "OneOrMany<_, PreferOne>")]
pub pc_requirements: Vec<Requirements>,
#[serde_as(deserialize_as = "OneOrMany<_, PreferOne>")]
pub mac_requirements: Vec<Requirements>,
#[serde_as(deserialize_as = "OneOrMany<_, PreferOne>")]
pub linux_requirements: Vec<Requirements>,
pub developers: Option<Vec<String>>,
pub publishers: Option<Vec<String>>,
pub price_overview: Option<PriceOverview>,
pub packages: Option<Vec<u32>>,
pub package_groups: Option<Vec<PackageGroup>>,
pub platforms: Option<Platforms>,
pub categories: Option<Vec<Category>>,
pub screenshots: Option<Vec<Screenshot>>,
pub movies: Option<Vec<Movie>>,
pub recommendations: Option<Recommendations>,
pub release_date: Option<ReleaseDate>,
pub support_info: Option<SupportInfo>,
pub background: Option<String>,
pub background_raw: Option<String>,
pub content_descriptors: Option<ContentDescriptors>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Requirements {
pub minimum: Option<String>,
pub recommended: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct PriceOverview {
pub currency: Option<String>,
pub initial: Option<u32>,
#[serde(rename = "final")]
pub final_price: Option<u32>,
pub discount_percent: Option<u32>,
pub initial_formatted: Option<String>,
pub final_formatted: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct PackageGroup {
pub name: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub selection_text: Option<String>,
pub save_text: Option<String>,
pub display_type: Option<u32>,
pub is_recurring_subscription: Option<String>,
pub subs: Option<Vec<Sub>>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Sub {
pub packageid: Option<u32>,
pub percent_savings_text: Option<String>,
pub percent_savings: Option<u32>,
pub option_text: Option<String>,
pub option_description: Option<String>,
pub can_get_free_license: Option<String>,
pub is_free_license: Option<bool>,
pub price_in_cents_with_discount: Option<u32>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Platforms {
Expand All @@ -117,43 +57,21 @@ pub struct Platforms {
#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Category {
pub id: Option<u32>,
pub description: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Screenshot {
pub id: Option<u32>,
pub path_thumbnail: Option<String>,
pub path_full: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Movie {
pub id: Option<u32>,
pub name: Option<String>,
pub thumbnail: Option<String>,
pub webm: Option<Webm>,
pub mp4: Option<Mp4>,
pub highlight: Option<bool>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Webm {
#[serde(rename = "480°")]
pub _480: Option<String>,
pub max: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct Mp4 {
#[serde(rename = "480°")]
pub _480: Option<String>,
pub max: Option<String>,
}

#[serde_as]
Expand All @@ -169,20 +87,6 @@ pub struct ReleaseDate {
pub date: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct SupportInfo {
pub url: Option<String>,
pub email: Option<String>,
}

#[serde_as]
#[derive(Deserialize, Clone, Debug)]
pub struct ContentDescriptors {
pub ids: Vec<u32>,
pub notes: Option<String>,
}

impl SteamGameWrapper {
/// `new_steam_game_by_id` is an asynchronous function that creates a new `SteamGameWrapper` by the given app id.
/// It takes an `appid` and `guild_id` as parameters.
Expand Down

0 comments on commit a994e6e

Please sign in to comment.