diff --git a/data.db b/data.db new file mode 100644 index 0000000..4c77275 Binary files /dev/null and b/data.db differ diff --git a/src/spoiler_mangas/mod.rs b/src/spoiler_mangas/mod.rs index 9e60fc4..4171eea 100644 --- a/src/spoiler_mangas/mod.rs +++ b/src/spoiler_mangas/mod.rs @@ -10,8 +10,8 @@ use image::{DynamicImage,GenericImageView}; use std::io::Cursor; use tokio::io::BufStream; -const TOLERANCE: i16 = 10; -const PERCENT_ACEPTANCE: u8 = 15; +const TOLERANCE: i16 = 0; +const PERCENT_ACEPTANCE: u8 = 5; fn check_percent(img: DynamicImage) -> u8 { let mut cont = 0; @@ -64,6 +64,7 @@ pub async fn check_image(msg: Message, bot: Bot) -> anyhow::Result<()> { Some(s) => { let mut percent = 0; let mut id : Option<(String, u32)> = None; + let mut failed = true; for p in s { let file = bot.get_file(p.file.id.clone()).await?; let empty_memory: Vec = Vec::new(); @@ -73,6 +74,7 @@ pub async fn check_image(msg: Message, bot: Bot) -> anyhow::Result<()> { let raw = reader.into_inner().into_inner().leak(); match image::load_from_memory(raw) { Ok(img) => { + failed = false; let img_percent = check_percent(img); if img_percent >= percent { percent = img_percent; @@ -91,7 +93,7 @@ pub async fn check_image(msg: Message, bot: Bot) -> anyhow::Result<()> { Err(_e) => continue, } } - if percent < PERCENT_ACEPTANCE { + if !failed && percent < PERCENT_ACEPTANCE { bot.delete_message(msg.chat.id, msg.id).await?; let response = match id { Some(i) => bot.send_photo(msg.chat.id, teloxide::types::InputFile::file_id(i.0)).has_spoiler(true),