sneakycrow / gwitch

a gleam lib for connecting to twitch IRC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gwitch

A library for reading and writing messages to Twitch IRC

Package Version Hex Docs

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.

About

a gleam lib for connecting to twitch IRC

License:Apache License 2.0


Languages

Language:Gleam 100.0%