async fn run() {
    use tokio_stream::wrappers::UnboundedReceiverStream;

    teloxide::enable_logging!();
    log::info!("Starting dialogue bot...");

    let bot = Bot::from_env().auto_send();

    let args: Vec<String> = std::env::args().collect();
    let config = parse_args(args);

    let db_shared: Arc<Mutex<RedisConnection>> = Arc::new(Mutex::new(
        match db::RedisConnection::new(&config.redis_ip[..]).await {
            Ok(v) => v,
            Err(err) => panic!("Could not start redis connection: {}", err),
        },
    ));

    Dispatcher::new(bot)
        .messages_handler(
            |rx: UnboundedReceiver<UpdateWithCx<AutoSend<Bot>, Message>>| async move {
                UnboundedReceiverStream::new(rx)
                    .for_each_concurrent(None, |cx| async {
                        handle_message(cx, db_shared.clone()).await
                    })
                    .await;
            },
        )
        .dispatch()
        .await;
    log::info!("Closing the bot...");
}
/// Main run function.
///
/// Sets everything up and starts the bot.
Main run function.
Sets everything up and starts the bot.
Main run function . Sets everything up and starts the bot .
async fn run() {
    use tokio_stream::wrappers::UnboundedReceiverStream;
    teloxide::enable_logging!();
    log::info!("Starting dialogue bot...");
    let bot = Bot::from_env().auto_send();
    let args: Vec<String> = std::env::args().collect();
    let config = parse_args(args);
    let db_shared: Arc<Mutex<RedisConnection>> = Arc::new(Mutex::new(
        match db::RedisConnection::new(&config.redis_ip[..]).await {
            Ok(v) => v,
            Err(err) => panic!("Could not start redis connection: {}", err),
        },
    ));
    Dispatcher::new(bot)
        .messages_handler(
            |rx: UnboundedReceiver<UpdateWithCx<AutoSend<Bot>, Message>>| async move {
                UnboundedReceiverStream::new(rx)
                    .for_each_concurrent(None, |cx| async {
                        handle_message(cx, db_shared.clone()).await
                    })
                    .await;
            },
        )
        .dispatch()
        .await;
    log::info!("Closing the bot...");
}
async fn run ( ) { use tokio_stream :: wrappers :: UnboundedReceiverStream ; teloxide :: enable_logging ! ( ) ; log :: info ! ( " " ) ; let bot = Bot :: from_env ( ) . auto_send ( ) ; let args : Vec < String > = std :: env :: args ( ) . collect ( ) ; let config = parse_args ( args ) ; let db_shared : Arc < Mutex < RedisConnection > > = Arc :: new ( Mutex :: new ( match db :: RedisConnection :: new ( & config . redis_ip [ .. ] ) . await { Ok ( v ) => v , Err ( err ) => panic ! ( " " err ) , } , ) ) ; Dispatcher :: new ( bot ) . messages_handler ( | rx : UnboundedReceiver < UpdateWithCx < AutoSend < Bot > , Message > > | async move { UnboundedReceiverStream :: new ( rx ) . for_each_concurrent ( None , | cx | async { handle_message ( cx , db_shared . clone ( ) ) . await } ) . await ; } , ) . dispatch ( ) . await ; log :: info ! ( " " ) ; }
Main run function.
Main run function .