From 2c45e4fa44e22e7ff7f1995552b77e20ac2d3658 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:23:57 +0200 Subject: [PATCH] move generic bot download function to its own function to avoid code duplication --- src/bot/bot.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bot/bot.rs b/src/bot/bot.rs index 81ea88a..ba95dc6 100644 --- a/src/bot/bot.rs +++ b/src/bot/bot.rs @@ -83,7 +83,7 @@ async fn cmd_test(bot: Bot, msg: Message) -> HandlerResult { Ok(()) } -async fn cmd_download(bot: Bot, msg: Message, url: String) -> HandlerResult { +async fn bot_download(bot: Bot, msg: Message, url: String) -> HandlerResult { let output_path = match download(url.as_str()).await { Ok(path) => path, Err(e) => { @@ -103,6 +103,10 @@ async fn cmd_download(bot: Bot, msg: Message, url: String) -> HandlerResult { Ok(()) } +async fn cmd_download(bot: Bot, msg: Message, url: String) -> HandlerResult { + bot_download(bot, msg, url).await +} + async fn handle_message(_bot: Bot, _dialogue: MyDialogue, msg: Message) -> HandlerResult { Ok(()) }