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