# refluxer
Rust API wrapper for [Fluxer](https://fluxer.app) — a free and open source instant messaging and VoIP platform.
## Features
- **HTTP REST API** — typed client for Fluxer's HTTP API with rate limiting
- **WebSocket Gateway** — real-time event stream with auto-reconnect
- **High-level Client** — event handler framework for building bots
- **Feature flags** — include only what you need
## Quick Start
```toml
[dependencies]
refluxer = { version = "0.1", features = ["client"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
async-trait = "0.1"
```
```rust
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.content == "!ping" {
ctx.send_message(msg.channel_id, "Pong!").await.ok();
}
}
}
#[tokio::main]
async fn main() -> Result<(), refluxer::Error> {
let client = Client::builder()
.token("your_bot_token")
.event_handler(Handler)
.build()?;
client.start().await
}
```
## Feature Flags
| `http` | REST client + models | yes |
| `gateway` | WebSocket Gateway (includes `http`) | no |
| `client` | High-level framework (includes `gateway`) | no |
## HTTP-Only Usage
```toml
[dependencies]
refluxer = "0.1" # default features = ["http"]
```
```rust
let http = refluxer::HttpClient::new("your_token")?;
let user = http.get_current_user().await?;
```
## Self-Hosted Instances
```rust
let http = refluxer::HttpClient::builder()
.token("your_token")
.base_url("https://my-fluxer.example.com/v1")
.build()?;
```
## Examples
Lightweight examples live in `refluxer/examples`:
```sh
FLUXER_TOKEN=your_token cargo run -p refluxer --example ping_bot --features client
FLUXER_TOKEN=your_token cargo run -p refluxer --example http_only
```
Dependency-heavy examples are standalone Cargo projects so they do not affect
the main crate's dependency graph:
```sh
cargo run --manifest-path examples/gitbot/Cargo.toml
cargo run --manifest-path examples/card_bot/Cargo.toml
```
Bot examples require `FLUXER_TOKEN`. `card_bot` also requires `OPENAI_API_KEY`.
## Release Checks
```sh
cargo fmt --all --check
cargo test --workspace --all-features --lib
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --manifest-path examples/gitbot/Cargo.toml
cargo test --manifest-path examples/card_bot/Cargo.toml
```
## Publishing
Publishing is automated by GitHub Actions when a `v*` tag is pushed. The tag
version must match the crate version, for example `v0.2.0`.
The repository must have a `CARGO_REGISTRY_TOKEN` secret with permission to
publish `refluxer`.
## License
MIT