twitchalerts

Crates.iotwitchalerts
lib.rstwitchalerts
version0.1.5
sourcesrc
created_at2023-04-09 00:46:37.282447
updated_at2023-10-24 18:56:06.316652
descriptionA crate which when it detect that a streamer is live which trigger the event handler, more features to be added.
homepagehttps://crates.io/crates/twitchalerts
repositoryhttps://github.com/concelaredev/twitchalerts
max_upload_size
id833867
size32,180
(Concelare)

documentation

https://docs.rs/twitchalerts

README

Rust TwitchAlerts

A rust crate to allow the users to detect when a streamer is live a trigger a custom event. Rate Limiting is currently hardcoded at 80ms between individual checks but the delay between Check Cycles is fully customisable. Each streamer can currently be checked once every 30 seconds.

If you find any bugs or have a feature request, please report them on GitHub and any improvements and additions are welcome through pull requests

Features

  • Stream Alerts
  • Custom Delay
  • Custom Error Handling

Setup

The first run will create a config file, this should contain the client-id, token, delay and list of streamers to monitor.

To get your OAuth token for twitch go to https://dev.twitch.tv/console create an application and use the Client ID & Secret with the command below

curl -X POST 'https://id.twitch.tv/oauth2/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=<your client id goes here>&client_secret=<your client secret goes here>&grant_type=client_credentials'

Example Config

streamers = ["streamer", "streamer2"]
delay = 80
token = "my_token"
user_id = "my_user_id"

Example

use async_trait::async_trait;
use twitchalerts::client::{StreamData, Streamer, Client};
use twitchalerts::traits::EventHandler;

pub struct Handler;

#[async_trait]
impl EventHandler for Handler {
    async fn on_stream(&self, streamer: &String, stream: &StreamData) {
        !todo();
    }

    async fn on_error(&self, error: String) {
        !todo();
    }
}

async fn main() -> Result<(), ()> {
    _ = Client::new("client id", "client token").event_handler(Handler).run().await?;

    Ok(())
}

Dependencies

Contributors

Commit count: 20

cargo fmt