Crates.io | vkontakte-bot |
lib.rs | vkontakte-bot |
version | 0.1.0 |
source | src |
created_at | 2024-06-13 06:53:29.905619 |
updated_at | 2024-06-22 18:47:05.989494 |
description | Library for creating bots for the VK social network. |
homepage | https://github.com/MayorDi/vkontakte-bot |
repository | https://github.com/MayorDi/vkontakte-bot |
max_upload_size | |
id | 1270267 |
size | 56,605 |
VKontakte-bot
- это маленькая библиотека, создана в целях практики.
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();
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();