-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeyboard.rs
52 lines (45 loc) · 1.42 KB
/
keyboard.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use tbot::{
prelude::*,
types::keyboard::inline::button::{self, Button},
Bot,
};
const TUTORIAL: &str = "https://gitlab.com/SnejUgal/tbot/wikis/Tutorial";
#[tokio::main]
async fn main() {
let mut bot = Bot::from_env("BOT_TOKEN").event_loop();
bot.command("keyboard", |context| async move {
let keyboard = vec![
vec![
Button::new("Cool!", button::Kind::with_callback_data("cool")),
Button::new(
"Amazing!",
button::Kind::with_callback_data("amazing"),
),
],
vec![Button::new(
"I wanna get started with it!",
button::Kind::with_url(TUTORIAL),
)],
];
let call_result = context
.send_message("This is a keyboard done with tbot!")
.reply_markup(keyboard)
.call()
.await;
if let Err(err) = call_result {
dbg!(err);
}
});
bot.message_data_callback(|context| async move {
let message = match context.data.as_str() {
"cool" => "You're cool too!",
"amazing" => "Thanks, I'm trying!",
_ => "Are you trying to hack me?",
};
let call_result = context.notify(message).call().await;
if let Err(err) = call_result {
dbg!(err);
}
});
bot.polling().start().await.unwrap();
}