Documentation ¶
Overview ¶
Package ircon maintains a connection to the Twitch IRC service.
Index ¶
Constants ¶
const ( // DefaultIRCServer is the default Twitch IRC server DefaultIRCServer = "ircs://irc.chat.twitch.tv:6697/" // DefaultWebChat is the default Twitch "IRC" server used by e.g. web chat DefaultWebChat = "wss://irc-ws.chat.twitch.tv/" // DefaultServer is the default server. DefaultServer = DefaultIRCServer )
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.
Variables ¶
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 IRCHandshake ¶ added in v0.2.0
type IRCHandshake struct { // Caps contains the set of capabilities that are requested on connect. // Advanced users can specify their own set. Caps string Nick string Ident string GECOS string Passwd string }
IRCHandshake implements a standard pre-registered-state handshake for the IRC protocol.
func TwitchHandshaker ¶ added in v0.2.0
func TwitchHandshaker(nick, passwd string) IRCHandshake
TwitchHandshaker creates an IRCHandshake with some Twitch-specific details.
func (IRCHandshake) Handshake ¶ added in v0.2.0
func (irc IRCHandshake) Handshake(con Sender) error
type IRCon ¶
type IRCon struct { // Server allows connecting to a different TMI server. Server string // contains filtered or unexported fields }
An IRCon is an automatically reconnecting IRC connection.
func New ¶
func New(d irc.Dialer, h Handshaker) *IRCon
New creates a new IRCon with the given credentials.
func (*IRCon) Run ¶
Run maintains a connection to the IRC server until the context is done.
func (*IRCon) Send ¶
Send sends a message to the currently active IRC connection. If there is no active connection, the message is lost.
TODO: typically we want to associate message sending with a specific connection instance, and not confuse it during reconnects. TODO: make a variant that can wait for a succesful connection.