do renaming for command handlers so it wouldn't conflict with other functions
This commit is contained in:
parent
f9682f28d2
commit
d8ea0e7490
3 changed files with 7 additions and 28 deletions
|
|
@ -53,8 +53,8 @@ fn schema() -> UpdateHandler<HandlerErr> {
|
|||
use dptree::case;
|
||||
|
||||
let command_handler = teloxide::filter_command::<Command, _>()
|
||||
.branch(case![Command::Test].endpoint(test))
|
||||
.branch(case![Command::Download(url)].endpoint(download));
|
||||
.branch(case![Command::Test].endpoint(cmd_test))
|
||||
.branch(case![Command::Download(url)].endpoint(cmd_download));
|
||||
|
||||
let message_handler = Update::filter_message().branch(command_handler);
|
||||
let raw_message_handler = Update::filter_message().branch(dptree::endpoint(handle_message));
|
||||
|
|
@ -73,13 +73,13 @@ enum Command {
|
|||
Download(String),
|
||||
}
|
||||
|
||||
async fn test(bot: Bot, msg: Message) -> HandlerResult {
|
||||
async fn cmd_test(bot: Bot, msg: Message) -> HandlerResult {
|
||||
bot.send_message(msg.chat.id, "test response").await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn download(bot: Bot, msg: Message, url: String) -> HandlerResult {
|
||||
async fn cmd_download(bot: Bot, msg: Message, url: String) -> HandlerResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ pub enum YtDlpError {
|
|||
ErrorMessage(String), // keep it separate type if we ever plan to parse yt-dlp errors
|
||||
JsonError,
|
||||
}
|
||||
// ^(?:ERROR: \[.*\] \S* )(.*$) - regex for matching yt-dlp's youtube errors
|
||||
|
||||
impl From<SpawnError> for YtDlpError {
|
||||
fn from(value: SpawnError) -> Self {
|
||||
|
|
|
|||
26
src/main.rs
26
src/main.rs
|
|
@ -1,37 +1,15 @@
|
|||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
|
||||
mod bot;
|
||||
use bot::bot::bot_main;
|
||||
|
||||
mod dl;
|
||||
use dl::ffmpeg::FFMpeg;
|
||||
use dl::yt_dlp::YtDlp;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
//dotenv::from_filename(".env.test").ok();
|
||||
|
||||
let info = YtDlp::load_info(env::var("TEST_URL")?.as_str())
|
||||
.await
|
||||
.expect("load_info");
|
||||
for format in &info.formats {
|
||||
println!("{}", format);
|
||||
}
|
||||
println!("");
|
||||
|
||||
let video = info.best_av_format().unwrap();
|
||||
println!("{}", video);
|
||||
|
||||
let audio = info.best_audio_format().unwrap();
|
||||
println!("{}", audio);
|
||||
|
||||
println!("abr {}", FFMpeg::round_mp3_bitrate(129.492));
|
||||
|
||||
FFMpeg::convert_to_mp3("audio.m4a", "audio.mp3", 160)
|
||||
.await
|
||||
.expect("convert");
|
||||
|
||||
bot_main().await?;
|
||||
Ok(())
|
||||
//bot_main().await
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue