Function grammers_client::types::reply_markup::keyboard

source ·
pub fn keyboard<B: Into<Vec<Vec<Keyboard>>>>(buttons: B) -> Keyboard
Expand description

Define a custom keyboard, replacing the user’s own virtual keyboard.

This will be displayed below the input message field for users, and on mobile devices, this also hides the virtual keyboard (effectively “replacing” it).

You cannot add images to the buttons, but you can use emoji (simply copy-paste them into your code, or use the correct escape sequence, or using any other input methods you like).

You will need to provide a matrix of button::Inline, that is, a vector that contains the rows from top to bottom, where the rows consist of a vector of buttons from left to right. See the button module to learn what buttons are available.

See the return type for further configuration options.

§Examples

use grammers_client::{InputMessage, reply_markup, button};

client.send_message(chat, InputMessage::text("What do you want to do?").reply_markup(&reply_markup::keyboard(vec![
    vec![button::text("Accept")],
    vec![button::text("Cancel"), button::text("Try something else")],
]))).await?;