8 releases (5 breaking)
0.6.0 | Jun 12, 2024 |
---|---|
0.5.0 | Jul 25, 2022 |
0.4.0 | Jul 28, 2021 |
0.3.0 | Jul 26, 2021 |
0.1.0 | Jul 5, 2021 |
#122 in HTTP client
393 downloads per month
58KB
1K
SLoC
trovo-rs
A Rust api & chat client for Trovo.
It currently doesn't support all of the trovo api, feel free to open a PR adding new endpoints.
Example
Find a user by username and then connect to their chat.
use futures::prelude::*;
use std::{env, error::Error};
use trovo::ClientId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client_id = env::var("CLIENT_ID").expect("missing CLIENT_ID env var");
let username = env::var("USER_NAME").expect("missing USER_NAME env var");
let client = trovo::Client::new(ClientId::new(client_id));
println!("looking up user '{}'", username);
let user = client
.user(username)
.await?
.expect("no user found for the given username");
println!("found user {:#?}", user);
let mut messages = client.chat_messages_for_channel(&user.channel_id).await?;
println!("listening for chat messages");
while let Some(msg) = messages.next().await {
let msg = msg?;
println!("[{}] {}", msg.nick_name, msg.content);
}
Ok(())
}
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~8–20MB
~267K SLoC