Rust API wrapper for Fluxer, a free and open source instant messaging and VoIP platform.
- Typed HTTP client for Fluxer's REST API
- WebSocket gateway connection with heartbeat and reconnect support
- High-level bot client with event handlers and a shared context
- Strongly typed models, IDs, permissions, and snowflake support
- Feature flags for keeping dependency sets small
[dependencies]
refluxer = { version = "0.2", features = ["client"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
async-trait = "0.1"For HTTP-only usage, the default http feature is enough:
[dependencies]
refluxer = "0.2"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }use refluxer::model::message::Message;
use refluxer::{Client, Context, EventHandler};
struct Handler;
#[async_trait::async_trait]
impl EventHandler for Handler {
async fn message_create(&self, ctx: Context, msg: Message) {
if msg.author.bot.unwrap_or(false) {
return;
}
if msg.content == "!ping" {
ctx.send_message(msg.channel_id, "Pong!").await.ok();
}
}
}
#[tokio::main]
async fn main() -> Result<(), refluxer::Error> {
let token = std::env::var("FLUXER_TOKEN").expect("FLUXER_TOKEN env var required");
let client = Client::builder()
.token(&token)
.event_handler(Handler)
.build()?;
client.start().await
}use refluxer::HttpClient;
#[tokio::main]
async fn main() -> Result<(), refluxer::Error> {
let token = std::env::var("FLUXER_TOKEN").expect("FLUXER_TOKEN env var required");
let http = HttpClient::new(&token)?;
let me = http.get_current_user().await?;
println!("Logged in as {}#{}", me.username, me.discriminator);
Ok(())
}Self-hosted Fluxer instances can be configured with the builder:
let http = refluxer::HttpClient::builder()
.token("your_token")
.base_url("https://my-fluxer.example.com/v1")
.build()?;| Feature | Description | Default |
|---|---|---|
http |
REST client and shared models | yes |
gateway |
WebSocket gateway support, includes http |
no |
client |
High-level bot framework, includes gateway |
no |
Lightweight examples live in refluxer/examples:
FLUXER_TOKEN=your_token cargo run -p refluxer --example http_only
FLUXER_TOKEN=your_token cargo run -p refluxer --example ping_bot --features client
FLUXER_TOKEN=your_token cargo run -p refluxer --example reminder_bot --features client
FLUXER_TOKEN=your_token cargo run -p refluxer --example translator_bot --features clientDependency-heavy examples are standalone Cargo projects:
cargo run --manifest-path examples/gitbot/Cargo.toml
cargo run --manifest-path examples/card_bot/Cargo.tomlBot examples require FLUXER_TOKEN. card_bot also requires
OPENAI_API_KEY.
cargo build --workspace
cargo test --workspace
cargo fmt --all --check
cargo clippy --workspace --all-targets --all-featuresFluxer-backed integration tests require FLUXER_TOKEN and FLUXER_GUILD_ID.
Run them serially to avoid shared remote-state conflicts:
cargo test -p refluxer --features client -- --test-threads=1Publishing is automated by GitHub Actions when a v* tag is pushed. The tag
version must match refluxer/Cargo.toml, for example v0.2.0.
The repository must have a CARGO_REGISTRY_TOKEN secret with permission to
publish refluxer.
MIT