Skip to content

Commit 232323f

Browse files
committed
Update README
1 parent 827d6d5 commit 232323f

1 file changed

Lines changed: 64 additions & 33 deletions

File tree

README.md

Lines changed: 64 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
# refluxer
22

3-
Rust API wrapper for [Fluxer](https://fluxer.app) — a free and open source instant messaging and VoIP platform.
3+
Rust API wrapper for [Fluxer](https://fluxer.app), a free and open source
4+
instant messaging and VoIP platform.
45

56
## Features
67

7-
- **HTTP REST API** — typed client for Fluxer's HTTP API with rate limiting
8-
- **WebSocket Gateway** — real-time event stream with auto-reconnect
9-
- **High-level Client** — event handler framework for building bots
10-
- **Feature flags** — include only what you need
8+
- Typed HTTP client for Fluxer's REST API
9+
- WebSocket gateway connection with heartbeat and reconnect support
10+
- High-level bot client with event handlers and a shared context
11+
- Strongly typed models, IDs, permissions, and snowflake support
12+
- Feature flags for keeping dependency sets small
1113

12-
## Quick Start
14+
## Installation
1315

1416
```toml
1517
[dependencies]
16-
refluxer = { version = "0.1", features = ["client"] }
18+
refluxer = { version = "0.2", features = ["client"] }
1719
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
1820
async-trait = "0.1"
1921
```
2022

23+
For HTTP-only usage, the default `http` feature is enough:
24+
25+
```toml
26+
[dependencies]
27+
refluxer = "0.2"
28+
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
29+
```
30+
31+
## Quick Start
32+
2133
```rust
2234
use refluxer::model::message::Message;
2335
use refluxer::{Client, Context, EventHandler};
@@ -27,6 +39,10 @@ struct Handler;
2739
#[async_trait::async_trait]
2840
impl EventHandler for Handler {
2941
async fn message_create(&self, ctx: Context, msg: Message) {
42+
if msg.author.bot.unwrap_or(false) {
43+
return;
44+
}
45+
3046
if msg.content == "!ping" {
3147
ctx.send_message(msg.channel_id, "Pong!").await.ok();
3248
}
@@ -35,36 +51,35 @@ impl EventHandler for Handler {
3551

3652
#[tokio::main]
3753
async fn main() -> Result<(), refluxer::Error> {
54+
let token = std::env::var("FLUXER_TOKEN").expect("FLUXER_TOKEN env var required");
55+
3856
let client = Client::builder()
39-
.token("your_bot_token")
57+
.token(&token)
4058
.event_handler(Handler)
4159
.build()?;
4260

4361
client.start().await
4462
}
4563
```
4664

47-
## Feature Flags
65+
## HTTP Client
4866

49-
| Feature | Description | Default |
50-
|-----------|--------------------------------------|:-------:|
51-
| `http` | REST client + models | yes |
52-
| `gateway` | WebSocket Gateway (includes `http`) | no |
53-
| `client` | High-level framework (includes `gateway`) | no |
67+
```rust
68+
use refluxer::HttpClient;
5469

55-
## HTTP-Only Usage
70+
#[tokio::main]
71+
async fn main() -> Result<(), refluxer::Error> {
72+
let token = std::env::var("FLUXER_TOKEN").expect("FLUXER_TOKEN env var required");
73+
let http = HttpClient::new(&token)?;
5674

57-
```toml
58-
[dependencies]
59-
refluxer = "0.1" # default features = ["http"]
60-
```
75+
let me = http.get_current_user().await?;
76+
println!("Logged in as {}#{}", me.username, me.discriminator);
6177

62-
```rust
63-
let http = refluxer::HttpClient::new("your_token")?;
64-
let user = http.get_current_user().await?;
78+
Ok(())
79+
}
6580
```
6681

67-
## Self-Hosted Instances
82+
Self-hosted Fluxer instances can be configured with the builder:
6883

6984
```rust
7085
let http = refluxer::HttpClient::builder()
@@ -73,39 +88,55 @@ let http = refluxer::HttpClient::builder()
7388
.build()?;
7489
```
7590

91+
## Feature Flags
92+
93+
| Feature | Description | Default |
94+
|-----------|----------------------------------------------|:-------:|
95+
| `http` | REST client and shared models | yes |
96+
| `gateway` | WebSocket gateway support, includes `http` | no |
97+
| `client` | High-level bot framework, includes `gateway` | no |
98+
7699
## Examples
77100

78101
Lightweight examples live in `refluxer/examples`:
79102

80103
```sh
81-
FLUXER_TOKEN=your_token cargo run -p refluxer --example ping_bot --features client
82104
FLUXER_TOKEN=your_token cargo run -p refluxer --example http_only
105+
FLUXER_TOKEN=your_token cargo run -p refluxer --example ping_bot --features client
106+
FLUXER_TOKEN=your_token cargo run -p refluxer --example reminder_bot --features client
107+
FLUXER_TOKEN=your_token cargo run -p refluxer --example translator_bot --features client
83108
```
84109

85-
Dependency-heavy examples are standalone Cargo projects so they do not affect
86-
the main crate's dependency graph:
110+
Dependency-heavy examples are standalone Cargo projects:
87111

88112
```sh
89113
cargo run --manifest-path examples/gitbot/Cargo.toml
90114
cargo run --manifest-path examples/card_bot/Cargo.toml
91115
```
92116

93-
Bot examples require `FLUXER_TOKEN`. `card_bot` also requires `OPENAI_API_KEY`.
117+
Bot examples require `FLUXER_TOKEN`. `card_bot` also requires
118+
`OPENAI_API_KEY`.
94119

95-
## Release Checks
120+
## Development
96121

97122
```sh
123+
cargo build --workspace
124+
cargo test --workspace
98125
cargo fmt --all --check
99-
cargo test --workspace --all-features --lib
100-
cargo clippy --workspace --all-targets --all-features -- -D warnings
101-
cargo test --manifest-path examples/gitbot/Cargo.toml
102-
cargo test --manifest-path examples/card_bot/Cargo.toml
126+
cargo clippy --workspace --all-targets --all-features
127+
```
128+
129+
Fluxer-backed integration tests require `FLUXER_TOKEN` and `FLUXER_GUILD_ID`.
130+
Run them serially to avoid shared remote-state conflicts:
131+
132+
```sh
133+
cargo test -p refluxer --features client -- --test-threads=1
103134
```
104135

105136
## Publishing
106137

107138
Publishing is automated by GitHub Actions when a `v*` tag is pushed. The tag
108-
version must match the crate version, for example `v0.2.0`.
139+
version must match `refluxer/Cargo.toml`, for example `v0.2.0`.
109140

110141
The repository must have a `CARGO_REGISTRY_TOKEN` secret with permission to
111142
publish `refluxer`.

0 commit comments

Comments
 (0)