forked from Skynet/discord-bot
feat: only need to keep whatever ones are in teh current season (if at all)
This commit is contained in:
parent
acdfe4b423
commit
1ff993d236
1 changed files with 33 additions and 0 deletions
|
@ -92,6 +92,9 @@ async fn update_icon_main(ctx: Arc<Context>) {
|
|||
|
||||
// get a list of all the graphics files
|
||||
let logos = get_logos(&config_global, &config_toml);
|
||||
|
||||
// filter them so only the current season (if any) are active
|
||||
let logos_filtered = logos_filter(&festival_data, logos);
|
||||
}
|
||||
|
||||
struct FestivalData{
|
||||
|
@ -263,3 +266,33 @@ fn get_logos(config: &Config, config_toml: &ConfigToml) -> Vec<LogoData> {
|
|||
|
||||
logos
|
||||
}
|
||||
|
||||
fn logos_filter(festival_data: &FestivalData, existing: Vec<LogoData>) -> Vec<LogoData>{
|
||||
let mut filtered: Vec<LogoData> = vec![];
|
||||
|
||||
for logo in existing {
|
||||
let name_lowercase0 = logo.name.to_ascii_lowercase();
|
||||
let name_lowercase = name_lowercase0.to_str().unwrap_or_default();
|
||||
|
||||
// if its a current festival filter based on it
|
||||
if let Some(x) = &festival_data.current {
|
||||
if name_lowercase.contains(x) {
|
||||
filtered.push(logo);
|
||||
}
|
||||
} else {
|
||||
// else filter using the excluded ones
|
||||
let mut excluded = false;
|
||||
for festival in &festival_data.exclusions {
|
||||
if name_lowercase.contains(festival) {
|
||||
excluded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if !excluded {
|
||||
filtered.push(logo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filtered
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue