From 6fee46fbbea4d38b3fc9e91ff9486714dc67d106 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Mon, 6 May 2024 22:27:31 +0200 Subject: [PATCH] Fix --- src/core/file_utils.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/file_utils.rs b/src/core/file_utils.rs index 5f94a0a..fe451dc 100644 --- a/src/core/file_utils.rs +++ b/src/core/file_utils.rs @@ -9,6 +9,7 @@ use teloxide::{ types::{ChatId, InputFile, MessageId}, Bot, }; +use tracing::log; use tokio::io::AsyncRead; use tokio_util::compat::FuturesAsyncReadCompatExt; @@ -68,11 +69,17 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Option { if message.document() == None { - return Option::None; + return None; } let file_id = message.document().unwrap().file.id.clone(); - let path = bot.get_file(file_id.clone()).await.unwrap().path; + let path = match bot.get_file(file_id.clone()).await { + Ok(v) => v.path, + Err(err) => { + log::error!("Error: {}", err); + return None; + }, + }; return Some(BotDownloader::new(bot, path)); }