Expand description
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(())
}Modules§
- chat
- Chat
Structs§
- Access
Token Expired - Error returned by
AccessTokenOnlywhenrefresh_tokenis called. - Access
Token Only - A simple access token provider that errors if refreshing is attempted. It is strongly advised
that you implement your own
AccessTokenProviderso that you can handle refreshing. - ApiError
- Struct representing errors that trovo api responds with.
- Channel
Emotes - Channel id and its emotes
- Channel
Info - Response for the get users api
- Channel
Update - Fields to update on a channel
- Channel
Update Payload - Payload for the channel update endpoint
- Client
- Entrypoint for making requests to the Trovo api.
- Client
Id - A simple client id provider that simply wraps the client id string
- Customized
Emotes - Container for customized emotes
- Emote
- Common emote payload across types
- Emote
Channels - Map of different emote types
- GetChannel
ById Payload - Payload for the get channel info by id api
- GetEmotes
Payload - Payload for the get emotes api call
- GetEmotes
Response - Response for the get emotes api
- GetUsers
Payload - Payload for the get users api
- GetUsers
Response - Response for the get users api
- Social
Link - Social media link for a channel
- User
- User details returned by
Client::users
Enums§
- Access
Token - Represents an access token
- Audience
Type - Audience type of a channel
- Authenticated
Request Error - Standard errors that can occur on most api calls
- Emote
Fetch Type - Types of emotes to fetch
- Error
Status - Error codes returned by the Trovo api
- Request
Error - Standard errors that can occur on most api calls
Traits§
- Access
Token Provider - A trait for an auth provider that can provide an access token.
- Client
IdProvider - A trait for an auth provider that can provide a client id