StrawHat.Twitch v0.0.2 StrawHat.Twitch.IRC.Server View Source

A GenServer that that uses a IRC Client.

password = System.get_env("TWITCH_CHAT_PASSWORD")
credentials = StrawHat.Twitch.IRC.Credentials.new("my_twitch_channel", password)
{:ok, pid} =
  StrawHat.Twitch.IRC.Server.start_link(:my_channel, %{
    credentials: credentials,
    message_broker: StrawHat.Twitch.IRC.MessageBroker.Echo
  })

Using the pid you can send messages to ohter channels

StrawHat.Twitch.IRC.Server.send_message(pid, "alchemist_ubi", "Hello, World")

Now you can subscribe to a channel chat's thread.

StrawHat.Twitch.IRC.Server.join_channel(pid, "alchemist_ubi")

Or unsubscribe from a channel chat's thread

StrawHat.Twitch.IRC.Server.leave_channel(pid, "alchemist_ubi")

Link to this section Summary

Types

Indentifier of the chat genserver

Functions

Subscribe to a channel, listening for incoming messages

Unsubscribe from a channel

Send a message to a channel

Starts a new Chat server

Link to this section Types

Link to this type

chat_server_pid() View Source
chat_server_pid() :: pid()

Indentifier of the chat genserver.

Link to this type

opts() View Source
opts() :: %{
  credentials: %StrawHat.Twitch.IRC.Credentials{
    password: term(),
    username: term()
  },
  message_broker: module(),
  host: binary()
}

Link to this section Functions

Link to this function

join_channel(pid, channel_name) View Source
join_channel(chat_server_pid(), String.t()) :: :ok

Subscribe to a channel, listening for incoming messages.

Link to this function

leave_channel(pid, channel_name) View Source
leave_channel(chat_server_pid(), String.t()) :: :ok

Unsubscribe from a channel.

Link to this function

send_message(pid, channel_name, message) View Source
send_message(chat_server_pid(), String.t(), String.t()) :: :ok

Send a message to a channel.

Link to this function

start_link(name, opts) View Source
start_link(chat_server_pid(), opts()) :: {:ok, pid()}

Starts a new Chat server.