gwitch

A library for reading and writing messages to Twitch IRC

Package Version Hex Docs

Features

Usage

gleam add gwitch
import gleam/erlang/process
import gwitch

pub fn main() {
  // Connect to the Twitch channel "criken" with an anonymous user, returning a subject to receive messages
  let subj = gwitch.connect("criken", None)
  // Start a process that will monitor the connection
  let done =
    // Create a selector that will receive messages from the WebSocket process
    process.new_selector()
    // Monitor for the WebSocket process to go down
    |> process.selecting_process_down(
      // Start the WebSocket monitoring process
      process.monitor_process(process.subject_owner(subj)),
      function.identity,
    )
    // Continously receive messages from the WebSocket process
    |> process.select_forever
}

Further documentation can be found at https://hexdocs.pm/gwitch.

Search Document