ircon

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2021 License: BSD-2-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package ircon maintains a connection to the Twitch IRC service.

Index

Constants

View Source
const DefaultCaps = "twitch.tv/tags twitch.tv/commands"

DefaultCaps is the default set of capabilities. The twitch.tv/membership capability is omitted for performance reasons and its general lack of usefulness in most scenarios.

View Source
const DefaultServer = "wss://irc-ws.chat.twitch.tv/"

DefaultServer is the default Twitch "IRC" server used by e.g. web chat

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Connected is called when a connection is fully established and the
	// connection is ready to send messages.
	Connected()

	// Disconnected is called when an active connection ends, potentially due
	// to an error. It will also be called when establishing a connection
	// fails, before it was fully Connected.
	Disconnected(err error)

	// Message is called for every incoming message. Note that it can be called
	// before Connected or after Disconnected are called.
	Message(*irc.Message)
}

A Handler receives events from IRCon.

type IRCon

type IRCon struct {
	// Caps contains the set of capabilities that are requested on connect.
	// Advanced users can specify their own set.
	Caps string

	Handler Handler
	// contains filtered or unexported fields
}

An IRCon is an automatically reconnecting IRC connection.

func New

func New(nick, passwd string) *IRCon

New creates a new IRCon with the given credentials.

func (*IRCon) Background

func (i *IRCon) Background(ctx context.Context)

Background runs the connection in a background goroutine until ctx is done.

func (*IRCon) Nick added in v0.1.3

func (i *IRCon) Nick() string

Nick returns the username or anonymous nickname used for this connection.

func (*IRCon) Send

func (i *IRCon) Send(s string)

Send sends a message to the currently active IRC connection. If there is no active connection, the message is lost.

type Message

type Message = irc.Message

Message aliases irc.Message for import convenience.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL