Crates.io | ataraxia |
lib.rs | ataraxia |
version | 0.1.0 |
source | src |
created_at | 2022-06-13 14:34:50.494514 |
updated_at | 2022-06-13 14:34:50.494514 |
description | A Rust Wrapper for the Revolt API |
homepage | https://github.com/rndrmu/ataraxia |
repository | https://github.com/rndrmu/ataraxia.git |
max_upload_size | |
id | 605137 |
size | 29,167 |
A minimal barebones API Wrapper for the revolt.chat API
use ataraxia::{
websocket::{Client, EventHandler},
models::message::Message as RevoltMessage,
context::Context,
async_trait
};
struct Handler;
#[async_trait]
impl EventHandler for Handler {
async fn authenticated(&self) {
println!("Authenticated!");
}
async fn ready(&self, _ctx: Context) {
println!("Ready!");
}
async fn on_message(&self, ctx: Context, message: RevoltMessage) {
println!("{}", message);
if message.content == "!ping" {
ctx.reply_builder(&message.channel_id, |r| {
r.content("Pong!")
}).await
}
}
#[tokio::main]
async fn main() {
let token = std::env::var("TOKEN").expect("token");
let mut client = Client::new(token)
.event_handler(Handler)
.set_api_url("https://api.revolt.chat");
client.start().await;
}