#api #chat #vk #api-bindings #v-kontakte

vkontakte-bot

Library for creating bots for the VK social network

3 unstable releases

new 0.1.0 Jun 22, 2024
0.0.2 Jun 14, 2024
0.0.1 Jun 13, 2024

#8 in #vk

Download history 244/week @ 2024-06-10 97/week @ 2024-06-17

341 downloads per month

Apache-2.0

47KB
349 lines

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();

Dependencies

~6–18MB
~267K SLoC