Crates.io | safe-vk |
lib.rs | safe-vk |
version | |
source | src |
created_at | 2024-01-17 12:49:37.667659 |
updated_at | 2024-11-08 16:22:25.790135 |
description | A simple library to create your own vk bot for conversations |
homepage | https://github.com/Azumi4han/safe-vk |
repository | https://github.com/Azumi4han/safe-vk |
max_upload_size | |
id | 1102903 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Rust library for creating your own VK bot for conversations in Rust 🦀
This library doesn’t include all VK API methods yet, but it has enough functionality to wrap around the ComfyUI API or even the oobabooga API. See more in the examples.
Ensure you have Rust stable version 1.82.0 or nightly version 1.84.0 installed. This library is tested and compatible with these versions.
routes
same as in popular web frameworks$ cargo add safe-vk
$ cargo update
use safe_vk::{extract::Ctx, responses::Message, Filter, Result, SafeVk};
use std::env;
async fn reply(update: Ctx<Message>) -> Result<()> {
update.messages().send().random_id(0).message("hi").await?;
Ok(())
}
#[tokio::main]
async fn main() {
let token = env::var("TOKEN").expect("TOKEN environment variable not set");
let bot = SafeVk::new().command("/hello", reply, Filter::Strict);
safe_vk::start_polling(&token, bot).await.unwrap();
}
For more, try to play with examples. To run an example, use the following command in your terminal:
$ TOKEN=YOUR_TOKEN cargo run --example reply
$ TOKEN=YOUR_TOKEN cargo run --example comfyui
$ TOKEN=YOUR_TOKEN cargo run --example oobabooga
$ TOKEN=YOUR_TOKEN cargo run --example macros
$ TOKEN=YOUR_TOKEN cargo run --example keyboard
$ TOKEN=YOUR_TOKEN cargo run --example members
$ TOKEN=YOUR_TOKEN cargo run --example state
Don't forget to include your token !
My primary goal with this project is to learn how to work with asynchronous code and understand Rust's strong, safe type system. This project is heavily inspired by the axum crate. Feel free to contribute and propose new ideas! Updates will be made as I have motivation and free time.
safe-vk
is available under the MIT license. See the MIT License file for more details