added HIDE_PORTFOLIO_ROW setting

This commit is contained in:
Djkato 2023-01-29 17:17:04 +01:00
parent 969abe34b4
commit 3d1bee87b6
5 changed files with 34 additions and 7 deletions

View file

@ -8,4 +8,8 @@ djkato.net
EXCLUDE_CHARACTERS_LIST:{ EXCLUDE_CHARACTERS_LIST:{
no_drp no_drp
}
HIDE_PORTFOLIO_ROW:{
no
} }

2
Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = 3
[[package]] [[package]]
name = "DRP_Creative" name = "DRP_Creative"
version = "0.1.2" version = "0.1.3"
dependencies = [ dependencies = [
"discord-rich-presence", "discord-rich-presence",
"lazy_static", "lazy_static",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "DRP_Creative" name = "DRP_Creative"
version = "0.1.2" version = "0.1.3"
edition = "2021" edition = "2021"
author = "https://djkato.net" author = "https://djkato.net"
@ -23,4 +23,4 @@ features = [
] ]
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
windres = "0.2.2" windres = "0.2.2"

View file

@ -5,6 +5,7 @@ pub struct Config {
pub exclude_keywords_list: Vec<String>, pub exclude_keywords_list: Vec<String>,
pub should_exclude_be_invisible: bool, pub should_exclude_be_invisible: bool,
pub portfolio_link: String, pub portfolio_link: String,
pub hide_portfolio_row: bool,
} }
impl Config { impl Config {
@ -36,7 +37,7 @@ fn parse_config_file(config_file: &String) -> Config {
let mut exclude_keywords_list: Vec<String> = Vec::new(); let mut exclude_keywords_list: Vec<String> = Vec::new();
let mut should_exclude_be_invisible = false; let mut should_exclude_be_invisible = false;
let mut portfolio_link = String::new(); let mut portfolio_link = String::new();
let mut hide_portfolio_row = false;
for (i, line) in config_file.lines().enumerate() { for (i, line) in config_file.lines().enumerate() {
if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") { if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") {
match config_file match config_file
@ -45,6 +46,7 @@ fn parse_config_file(config_file: &String) -> Config {
.expect("index out of bounds") .expect("index out of bounds")
.to_lowercase() .to_lowercase()
.as_str() .as_str()
.trim()
{ {
"n" => should_exclude_be_invisible = false, "n" => should_exclude_be_invisible = false,
"no" => should_exclude_be_invisible = false, "no" => should_exclude_be_invisible = false,
@ -69,11 +71,28 @@ fn parse_config_file(config_file: &String) -> Config {
portfolio_link = arg_line.to_string(); portfolio_link = arg_line.to_string();
} }
} }
if line.contains("HIDE_PORTFOLIO_ROW:") {
match config_file
.lines()
.nth(i + 1)
.expect("index out of bounds")
.to_lowercase()
.as_str()
.trim()
{
"n" => hide_portfolio_row = false,
"no" => hide_portfolio_row = false,
"y" => hide_portfolio_row = true,
"yes" => hide_portfolio_row = true,
_ => hide_portfolio_row = false,
}
}
} }
Config { Config {
exclude_keywords_list, exclude_keywords_list,
should_exclude_be_invisible, should_exclude_be_invisible,
portfolio_link, portfolio_link,
hide_portfolio_row,
} }
} }

View file

@ -61,14 +61,18 @@ fn main() {
prev_project_name = project_name.clone(); prev_project_name = project_name.clone();
let details = format!("Working on {}", &project_name.clone()); let details = format!("Working on {}", &project_name.clone());
//update activity //update activity
let state = format!("Portfolio: {}", &config.portfolio_link);
let activity = activity::Activity::new() let mut activity = activity::Activity::new()
.state(state.as_str())
.details(&details.as_str()) .details(&details.as_str())
.assets( .assets(
activity::Assets::new().large_image(current_app.drp_client_id.as_str()), activity::Assets::new().large_image(current_app.drp_client_id.as_str()),
) )
.timestamps(activity::Timestamps::new().start(start_time as i64)); .timestamps(activity::Timestamps::new().start(start_time as i64));
let state;
if !config.hide_portfolio_row {
state = format!("Portfolio: {}", &config.portfolio_link);
activity = activity.state(state.as_str());
}
//if discord client exists, update status //if discord client exists, update status
if let Some(dc) = discord_client.as_mut() { if let Some(dc) = discord_client.as_mut() {
match dc.set_activity(activity) { match dc.set_activity(activity) {