Skip to content

Handle both commands and messages #648

Answered by WaffleLapkin
Veetaha asked this question in Q&A
Discussion options

You must be logged in to vote

I've tried your first code example and it just works for me?...

Full code

use teloxide::{
    prelude::*,
    types::Update,
    utils::command::BotCommands,
};

#[tokio::main]
async fn main() {
    pretty_env_logger::init();
    log::info!("Starting test bot...");

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

    let handler = dptree::entry()
        .branch(Update::filter_my_chat_member().endpoint(a))
        .branch(Update::filter_message().filter_command::<Cmd>().endpoint(b))
        .branch(Update::filter_message().endpoint(c));

    Dispatcher::builder(bot, handler).build().setup_ctrlc_handler().dispatch().await;
}

#[derive(BotCommands, Clone)]
#[command(rename = "lowercase")]
enum 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Veetaha
Comment options

Answer selected by WaffleLapkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants