move to bot_main so I can test program without running huge teloxide
This commit is contained in:
parent
1970eeb1ec
commit
22987242f7
1 changed files with 7 additions and 5 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -35,6 +35,10 @@ where
|
|||
async fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
bot_main().await
|
||||
}
|
||||
|
||||
async fn bot_main() -> anyhow::Result<()> {
|
||||
let bot = Bot::new(env::var("BOT_TOKEN")?);
|
||||
let listener = Polling::builder(bot.clone())
|
||||
.timeout(Duration::from_secs(parse_env("POLLING_TIMEOUT")))
|
||||
|
|
@ -58,10 +62,9 @@ async fn main() -> anyhow::Result<()> {
|
|||
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));
|
||||
let command_handler = teloxide::filter_command::<Command, _>()
|
||||
.branch(case![Command::Test].endpoint(test))
|
||||
.branch(case![Command::Download(url)].endpoint(download));
|
||||
|
||||
let message_handler = Update::filter_message().branch(command_handler);
|
||||
let raw_message_handler = Update::filter_message().branch(dptree::endpoint(handle_message));
|
||||
|
|
@ -87,7 +90,6 @@ async fn test(bot: Bot, msg: Message) -> HandlerResult {
|
|||
}
|
||||
|
||||
async fn download(bot: Bot, msg: Message, url: String) -> HandlerResult {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue