#chat #vkontakte #bot-api #api-bindings #vk #networking #api

vkontakte-bot

Library for creating bots for the VK social network

3 unstable releases

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

#1558 in Web programming

Download history 1/week @ 2024-07-24 5/week @ 2024-09-11 3/week @ 2024-09-18 7/week @ 2024-09-25 3/week @ 2024-10-02

118 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
~245K SLoC