vkontakte-bot

Crates.iovkontakte-bot
lib.rsvkontakte-bot
version0.1.0
sourcesrc
created_at2024-06-13 06:53:29.905619
updated_at2024-06-22 18:47:05.989494
descriptionLibrary for creating bots for the VK social network.
homepagehttps://github.com/MayorDi/vkontakte-bot
repositoryhttps://github.com/MayorDi/vkontakte-bot
max_upload_size
id1270267
size56,605
Dmitriy Mayorov (MayorDi)

documentation

README

VKontakte-bot

VKontakte-bot - это маленькая библиотека, создана в целях практики.

Example

let access_token = "your token";
let group_id = 0; // id of your group

let api_settings = ApiSettings::new(access_token, "5.99");

let mut vk_bot = VkBot::new(group_id, api_settings);

vk_bot.command("/lang", |ctx| {
    ctx.reply("Rust").unwrap();
});

vk_bot.command("/name", |ctx| {
    ctx.reply("Bob").unwrap();
});

vk_bot.init().unwrap().run().unwrap();

Use regex

let access_token = "your token";
let group_id = 0; // id of your group

let api_settings = ApiSettings::new(access_token, "5.99");

let mut vk_bot = VkBot::new(group_id, api_settings);

vk_bot.command(r"/num (?P<num>\d*)", |ctx| {
    let res = &ctx.captures["num"];
    ctx.reply(format!("num: {}", res).as_str()).unwrap();
});

vk_bot.init().unwrap().run().unwrap();
Commit count: 12

cargo fmt