irc

package
v0.0.0-...-e17367a Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package irc provides a Twitch IRC client for chat message ingestion.

Index

Constants

View Source
const (
	// TwitchIRCServerTLS is the Twitch IRC server address for TLS connections.
	TwitchIRCServerTLS = "irc.chat.twitch.tv:6697"

	// TwitchIRCServer is the Twitch IRC server address (non-TLS, deprecated).
	// Prefer TwitchIRCServerTLS for secure connections.
	TwitchIRCServer = "irc.chat.twitch.tv:6667"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMode

type AuthMode string

AuthMode represents the IRC authentication mode.

const (
	// AuthModeAuthenticated uses OAuth token for full access.
	AuthModeAuthenticated AuthMode = "authenticated"
	// AuthModeAnonymous uses justinfan nick for read-only access.
	AuthModeAnonymous AuthMode = "anonymous"
)

type ChannelChangeHandler

type ChannelChangeHandler func(channel string, joined bool)

ChannelChangeHandler is called when channel join/part is requested.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Twitch IRC client.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient creates a new IRC client.

func (*Client) AuthMode

func (c *Client) AuthMode() AuthMode

AuthMode returns the current authentication mode.

func (*Client) Channels

func (c *Client) Channels() []string

Channels returns a list of currently joined channels.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect establishes a TLS connection to Twitch IRC. The context is used for cancellation during the connection process.

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect closes the IRC connection.

func (*Client) IsAnonymous

func (c *Client) IsAnonymous() bool

IsAnonymous returns true if the client is using anonymous (justinfan) mode. In anonymous mode, the client is read-only and cannot send messages.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns true if the client is connected.

func (*Client) Join

func (c *Client) Join(channel string) error

Join joins a channel.

func (*Client) Part

func (c *Client) Part(channel string) error

Part leaves a channel.

type ClientConfig

type ClientConfig struct {
	AuthMode        AuthMode // "authenticated" or "anonymous"
	Username        string   // Required for authenticated, optional for anonymous
	OAuthToken      string   // Required for authenticated, must be empty for anonymous
	OnMessage       MessageHandler
	OnChannelChange ChannelChangeHandler
}

ClientConfig holds IRC client configuration.

type Message

type Message struct {
	Channel     string
	Username    string
	DisplayName string
	Text        string
	Tags        map[string]string
	ReceivedAt  time.Time
}

Message represents a parsed IRC PRIVMSG.

type MessageHandler

type MessageHandler func(msg Message)

MessageHandler is called for each incoming chat message.

Jump to

Keyboard shortcuts

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