#chat

rocketchat

Rocket.Chat API Implemented in Rust

6 releases (3 breaking)

0.4.1 Nov 1, 2022
0.4.0 Oct 30, 2022
0.3.1 Oct 22, 2022
0.2.0 Oct 20, 2022
0.1.0 Oct 17, 2022

#123 in #chat

MIT license

13KB
289 lines

rocketchat

Rust API wrapper for the RocketChat API

crates.io MIT

Example

The library uses asynchronous HTTP client reqwest, so your Cargo.toml could look like this:

rocketchat = "0.4.0"
tokio = { version = "1", features = ["full"] }

When calling methods, you need to pass settings that can be created as follows:

Using username and password

use rocketchat::{LoginSettings, Settings};

let settings = Settings::Login(LoginSettings {
    username: "chuck_norris".to_string(),
    password: "supersecret".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Using auth token and user ID

use rocketchat::{AuthSettings, Settings};

let settings = Settings::Auth(AuthSettings {
    auth_token: "some_auth_token".to_string(),
    user_id: "some_user_id".to_string(),
    domain: "https://mydomain.com".to_string(),
});

Available API methods

Post Message

use rocketchat::methods::PostMessageMethod;

let result = PostMessageMethod {
    settings: &settings,
    room_id: "#channel".to_string(),
    text: Some("Some message with star emoji :star:".to_string()),
    ..Default::default()
}.call().await;

Channel Create

use rocketchat::methods::ChannelCreateMethod;

let result = ChannelCreateMethod {
    settings: &settings,
    name: "some-channel".to_string(),
    members: Some(vec!["rocket.cat".to_string()]),
    ..Default::default()
}.call().await;

License

MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Dependencies

~4–16MB
~217K SLoC