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

@ -9,3 +9,7 @@ djkato.net
EXCLUDE_CHARACTERS_LIST:{
no_drp
}
HIDE_PORTFOLIO_ROW:{
no
}

2
Cargo.lock generated
View file

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

View file

@ -1,6 +1,6 @@
[package]
name = "DRP_Creative"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
author = "https://djkato.net"

View file

@ -5,6 +5,7 @@ pub struct Config {
pub exclude_keywords_list: Vec<String>,
pub should_exclude_be_invisible: bool,
pub portfolio_link: String,
pub hide_portfolio_row: bool,
}
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 should_exclude_be_invisible = false;
let mut portfolio_link = String::new();
let mut hide_portfolio_row = false;
for (i, line) in config_file.lines().enumerate() {
if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") {
match config_file
@ -45,6 +46,7 @@ fn parse_config_file(config_file: &String) -> Config {
.expect("index out of bounds")
.to_lowercase()
.as_str()
.trim()
{
"n" => 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();
}
}
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 {
exclude_keywords_list,
should_exclude_be_invisible,
portfolio_link,
hide_portfolio_row,
}
}

View file

@ -61,14 +61,18 @@ fn main() {
prev_project_name = project_name.clone();
let details = format!("Working on {}", &project_name.clone());
//update activity
let state = format!("Portfolio: {}", &config.portfolio_link);
let activity = activity::Activity::new()
.state(state.as_str())
let mut activity = activity::Activity::new()
.details(&details.as_str())
.assets(
activity::Assets::new().large_image(current_app.drp_client_id.as_str()),
)
.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 let Some(dc) = discord_client.as_mut() {
match dc.set_activity(activity) {