fix ascii select file

This commit is contained in:
sad 2024-03-19 15:00:04 -06:00
parent 5287b54864
commit 512a406f43
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 28D3A882F3E6AD02
1 changed files with 7 additions and 4 deletions

View File

@ -67,7 +67,7 @@ fn select_random_file(dir: &str) -> Option<String> {
pub async fn handle_ascii_command<W: AsyncWriteExt + Unpin>(
writer: &mut W,
config: &Config, // Adjust the path as necessary to match your project structure
config: &Config,
command: &str,
channel: &str,
) -> Result<(), Box<dyn std::error::Error>> {
@ -143,13 +143,16 @@ async fn handle_specific_file<W: AsyncWriteExt + Unpin>(
channel: &str,
parts: &[&str],
) -> Result<(), Box<dyn Error>> {
let file_name = if parts.len() >= 3 {
parts[2..].join(" ")
println!("{:?}", parts);
let file_name = if parts.len() > 2 {
parts[1..].join(" ").replace(' ', "/")
} else {
parts[2].to_string()
parts.get(1).unwrap_or(&"").to_string()
};
println!("{:?}", file_name);
let file_path = format!("{}/{}.txt", config.ascii_art.clone().unwrap_or_else(|| "ascii_art".to_string()), file_name);
println!("{:?}", file_path);
send_ansi_art(writer, &file_path, config.pump_delay, channel).await
}