feat: got the logos, and converted them if needs be
This commit is contained in:
parent
0034bd34d6
commit
b4f6835704
1 changed files with 16 additions and 8 deletions
|
@ -7,7 +7,7 @@ use serenity::{
|
||||||
use skynet_discord_bot::common::database::{db_init, DataBase};
|
use skynet_discord_bot::common::database::{db_init, DataBase};
|
||||||
use skynet_discord_bot::{get_config, Config};
|
use skynet_discord_bot::{get_config, Config};
|
||||||
use std::{fs, process, sync::Arc};
|
use std::{fs, process, sync::Arc};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -91,7 +91,7 @@ async fn update_icon_main(ctx: Arc<Context>) {
|
||||||
let festival_data = get_festival(&config_toml);
|
let festival_data = get_festival(&config_toml);
|
||||||
|
|
||||||
// get a list of all the graphics files
|
// get a list of all the graphics files
|
||||||
get_logos(&config_global, &config_toml);
|
let logos = get_logos(&config_global, &config_toml);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_festival(config_toml: &ConfigToml)-> (Option<String>, Vec<String>){
|
fn get_festival(config_toml: &ConfigToml)-> (Option<String>, Vec<String>){
|
||||||
|
@ -184,7 +184,7 @@ fn convert_svg_to_png(original: &PathBuf, out: &PathBuf){
|
||||||
fs::write(out, &bytes).expect("TODO: panic message");
|
fs::write(out, &bytes).expect("TODO: panic message");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_logos(config: &Config, config_toml: &ConfigToml){
|
fn get_logos(config: &Config, config_toml: &ConfigToml) -> Vec<(OsString, PathBuf)> {
|
||||||
let folder = format!("{}/open-governance/{}", &config.home, &config_toml.source.directory);
|
let folder = format!("{}/open-governance/{}", &config.home, &config_toml.source.directory);
|
||||||
let folder_path = PathBuf::from(&folder);
|
let folder_path = PathBuf::from(&folder);
|
||||||
let paths = fs::read_dir(folder).unwrap();
|
let paths = fs::read_dir(folder).unwrap();
|
||||||
|
@ -198,10 +198,14 @@ fn get_logos(config: &Config, config_toml: &ConfigToml){
|
||||||
};
|
};
|
||||||
let mut r = Renderer::new(&args).unwrap();
|
let mut r = Renderer::new(&args).unwrap();
|
||||||
|
|
||||||
for path in paths {
|
let mut logos = vec![];
|
||||||
let tmp = path.unwrap();
|
|
||||||
|
for tmp in paths.flatten() {
|
||||||
let mut path_local = tmp.path().to_owned();
|
let path_local = tmp.path().to_owned();
|
||||||
|
let path_local2 = tmp.path().to_owned();
|
||||||
|
let temp2 = path_local2.file_name().unwrap();
|
||||||
|
let mut file_path = tmp.path();
|
||||||
|
|
||||||
match tmp.path().extension() {
|
match tmp.path().extension() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ext) => {
|
Some(ext) => {
|
||||||
|
@ -216,11 +220,15 @@ fn get_logos(config: &Config, config_toml: &ConfigToml){
|
||||||
log::error!("Failed to render {path_local:?}: {}", e)
|
log::error!("Failed to render {path_local:?}: {}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path_local = path_new;
|
file_path = path_new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
logos.push((temp2.to_owned(), file_path.to_owned()));
|
||||||
|
|
||||||
println!("Name: {}", &tmp.path().display());
|
println!("Name: {}", &tmp.path().display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logos
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue