Documentation
¶
Index ¶
- Constants
- func Logger(m Message, c ChannelWriter)
- type Channel
- func (c *Channel) Authenticate() error
- func (c *Channel) Connect() error
- func (c *Channel) Disconnect()
- func (c *Channel) GetConfig() Config
- func (c *Channel) Listen() error
- func (c *Channel) Reconnect() error
- func (c *Channel) Send(content string) error
- func (c *Channel) SendMessage(message *Message) error
- func (c *Channel) SetWriter(e Encoder)
- type ChannelWriter
- type Config
- type Decoder
- type Digester
- type Encoder
- type Message
Constants ¶
const ( // DefaultTwitchPort is Twitch's default IRC port DefaultTwitchPort = "6667" // DefaultTwitchTlsPort is Twitch's default IRC port for TLS connections DefaultTwitchTlsPort = "443" // DefaultTwitchURI is Twitch's default IRC server DefaultTwitchURI = "irc.chat.twitch.tv" // DefaultTwitchServer is a helper with the DefaultTwitchURI and // DefaultTwitchPort combined. DefaultTwitchServer = DefaultTwitchURI + ":" + DefaultTwitchPort // DefaultTwitchTlsServer is the default TLS server and port DefaultTwitchTlsServer = DefaultTwitchURI + ":" + DefaultTwitchTlsPort )
Variables ¶
This section is empty.
Functions ¶
func Logger ¶
func Logger(m Message, c ChannelWriter)
Logger is a digester that simply echoes out user's messages to stdout.
Types ¶
type Channel ¶
type Channel struct {
Config *Config
Digesters []Digester
// contains filtered or unexported fields
}
Channel represents a connected and active IRC channel.
func NewTwitchChannel ¶
func NewTwitchChannel(channelName, username, token string, tls bool, digesters ...Digester) *Channel
NewTwitchChannel creates an IRC channel with Twitch's default server and port.
func (*Channel) Authenticate ¶
Authenticate sends the PASS and NICK to authenticate against the server. It also sends the JOIN message in order to join the specified channel in the configuration.
func (*Channel) Disconnect ¶
func (c *Channel) Disconnect()
Disconnect ends the current listener and closes the TCP connection.
func (*Channel) Listen ¶
Listen enters a loop and starts decoding IRC messages from the connected channel. Decoded messages are pushed to the digesters to be handled.
func (*Channel) SendMessage ¶
SendMessage sends the supplied message to the Channel.
type ChannelWriter ¶
type ChannelWriter interface {
Send(content string) error
SendMessage(message *Message) error
GetConfig() Config
}
ChannelWriter represents a writer capable of sending messages to a channel.
type Config ¶
type Config struct {
ChannelName string
Server string
Username string
OAuthToken string
// contains filtered or unexported fields
}
Config contains fields required to connect to the IRC server.
type Digester ¶
type Digester func(m Message, c ChannelWriter)
Digester is a handler function for parsing and reacting to IRC chat messages. All digesters MUST be thread safe, they will be called from multiple go routines.
func CustomLogger ¶
CustomLogger will write the incoming messages to the supplied io.Writer.
type Message ¶
type Message struct {
Name string
Username string
Content string
Command string
Host string
Params []string
Time time.Time
}
Message is a decoded IRC message.
func PongMessage ¶
func PongMessage() *Message
PongMessage returns a Message struct containing a PONG message, which should be used as a response to Twitch's PING message