From 9a924c8c0d6051fe2831c871e37bbe80a0311f89 Mon Sep 17 00:00:00 2001 From: Oleg Sobolev Date: Mon, 25 Mar 2024 17:21:28 +0700 Subject: [PATCH] formatting --- src/player.rs | 2 +- src/telegram.rs | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/player.rs b/src/player.rs index 3fd424c..bdc5e42 100644 --- a/src/player.rs +++ b/src/player.rs @@ -1,5 +1,5 @@ -use std::{collections::VecDeque, fs::File, io::BufReader, thread, thread::JoinHandle}; use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink}; +use std::{collections::VecDeque, fs::File, io::BufReader, thread, thread::JoinHandle}; use crate::channel::{self, Requester, Responder, TryRecvError}; use crate::track::TrackInfo; diff --git a/src/telegram.rs b/src/telegram.rs index b3527b3..c8b453f 100644 --- a/src/telegram.rs +++ b/src/telegram.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use teloxide::{prelude::*, utils::command::BotCommands}; -use crate::{player::MusicPlayer, download}; +use crate::{download, player::MusicPlayer}; #[derive(BotCommands, Clone)] #[command( @@ -41,17 +41,15 @@ impl TelegramBot { cmd: Command, ) -> Result<(), teloxide::RequestError> { match cmd { - Command::Play(url) => { - match download::download_from_youtube(&url) { - Ok(track_info) => { - player.lock().unwrap().enqueue(track_info); - bot.send_message(msg.chat.id, "Added to the queue.").await?; - }, - Err(_) => { - bot.send_message(msg.chat.id, "Failed to download.").await?; - } + Command::Play(url) => match download::download_from_youtube(&url) { + Ok(track_info) => { + player.lock().unwrap().enqueue(track_info); + bot.send_message(msg.chat.id, "Added to the queue.").await?; } - } + Err(_) => { + bot.send_message(msg.chat.id, "Failed to download.").await?; + } + }, Command::Stop => { player.lock().unwrap().stop(); bot.send_message(msg.chat.id, "Stopped.").await?;