Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (51 sloc) 1.76 KB
use vk_bot::{
keyboard::{Button, Color, Keyboard},
Bot, Core, Event, Handler, Tester,
fn main() {
// A simple closure for convenience...
let simple_handler = |message| {
// ...that returns a handler!
Handler::new(move |ctx| {
// This handler just sets the text of the message and sends it.
eprintln!("{:?}", ctx.send());
// Create a keyboard.
let kbd = Keyboard::new(
// Vec of rows
// Row 0
Button::new("A", Color::Primary, None),
Button::new("B", Color::Default, Some(r#"{"a": "b"}"#.into())),
false, // One-time? (i.e. show only until a button is pressed on the keyboard?)
let core = Core::new()
Handler::new(move |ctx| {
ctx.response().set_message("Here you go:");
eprintln!("{:?}", ctx.send());
.regex("nice", simple_handler("Thanks!"))
.on(Event::NoMatch, simple_handler("I don't understand..."))
.payload(r#"{"a":"b"}"#, simple_handler("You pressed button B!"))
// accept all remaining payloads!
.dyn_payload(Tester::new(|_| true), simple_handler("Received a payload!"));
"your vk token", // VK token
"f123456", // Confirmation token (from Callback API settings)
1, // Group ID
"very_secure_phrase", // Secret (from Callback API settings)
12345, // Port
You can’t perform that action at this time.