formatting

This commit is contained in:
Oleg Sobolev 2024-03-25 17:21:28 +07:00
parent aa04c6ef5b
commit 9a924c8c0d
2 changed files with 10 additions and 12 deletions

View file

@ -1,5 +1,5 @@
use std::{collections::VecDeque, fs::File, io::BufReader, thread, thread::JoinHandle};
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink}; 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::channel::{self, Requester, Responder, TryRecvError};
use crate::track::TrackInfo; use crate::track::TrackInfo;

View file

@ -1,7 +1,7 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use teloxide::{prelude::*, utils::command::BotCommands}; use teloxide::{prelude::*, utils::command::BotCommands};
use crate::{player::MusicPlayer, download}; use crate::{download, player::MusicPlayer};
#[derive(BotCommands, Clone)] #[derive(BotCommands, Clone)]
#[command( #[command(
@ -41,17 +41,15 @@ impl TelegramBot {
cmd: Command, cmd: Command,
) -> Result<(), teloxide::RequestError> { ) -> Result<(), teloxide::RequestError> {
match cmd { match cmd {
Command::Play(url) => { Command::Play(url) => match download::download_from_youtube(&url) {
match download::download_from_youtube(&url) {
Ok(track_info) => { Ok(track_info) => {
player.lock().unwrap().enqueue(track_info); player.lock().unwrap().enqueue(track_info);
bot.send_message(msg.chat.id, "Added to the queue.").await?; bot.send_message(msg.chat.id, "Added to the queue.").await?;
}, }
Err(_) => { Err(_) => {
bot.send_message(msg.chat.id, "Failed to download.").await?; bot.send_message(msg.chat.id, "Failed to download.").await?;
} }
} },
}
Command::Stop => { Command::Stop => {
player.lock().unwrap().stop(); player.lock().unwrap().stop();
bot.send_message(msg.chat.id, "Stopped.").await?; bot.send_message(msg.chat.id, "Stopped.").await?;