Documentation ¶
Index ¶
- Variables
- func ParseMessage(line string) (string, *User, *Message)
- type Client
- func (c *Client) Connect() error
- func (c *Client) Depart(channel string)
- func (c *Client) Disconnect() error
- func (c *Client) Join(channel string)
- func (c *Client) OnConnect(callback func())
- func (c *Client) OnNewClearchatMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewNoticeMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewRoomstateMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewUnsetMessage(callback func(rawMessage string))
- func (c *Client) OnNewUsernoticeMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewUserstateMessage(callback func(channel string, user User, message Message))
- func (c *Client) OnNewWhisper(callback func(user User, message Message))
- func (c *Client) OnPingSent(callback func())
- func (c *Client) OnPongReceived(callback func())
- func (c *Client) OnUserJoin(callback func(channel, user string))
- func (c *Client) OnUserPart(callback func(channel, user string))
- func (c *Client) Say(channel, text string)
- func (c *Client) SetIRCToken(ircToken string)
- func (c *Client) Userlist(channel string) ([]string, error)
- func (c *Client) Whisper(username, text string)
- type Emote
- type Message
- type MessageType
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientDisconnected returned from Connect() when a Disconnect() was called ErrClientDisconnected = errors.New("client called Disconnect()") // ErrLoginAuthenticationFailed returned from Connect() when either the wrong or a malformed oauth token is used ErrLoginAuthenticationFailed = errors.New("login authentication failed") // ErrConnectionIsNotOpen is returned by Disconnect in case you call it without being connected ErrConnectionIsNotOpen = errors.New("connection is not open") // WriteBufferSize can be modified to change the write channel buffer size. Must be configured before NewClient is called to take effect WriteBufferSize = 512 // ReadBufferSize can be modified to change the read channel buffer size. Must be configured before NewClient is called to take effect ReadBufferSize = 64 )
Functions ¶
Types ¶
type Client ¶
type Client struct { IrcAddress string TLS bool // Option whether to send pings every `IdlePingInterval`. The IdlePingInterval is interrupted every time a message is received from the irc server // The variable may only be modified before calling Connect SendPings bool // IdlePingInterval is the interval at which to send a ping to the irc server to ensure the connection is alive. // The variable may only be modified before calling Connect IdlePingInterval time.Duration // PongTimeout is the time go-twitch-irc waits after sending a ping before issuing a reconnect // The variable may only be modified before calling Connect PongTimeout time.Duration // SetupCmd is the command that is ran on successful connection to Twitch. Useful if you are proxying or something to run a custom command on connect. // The variable must be modified before calling Connect or the command will not run. SetupCmd string // contains filtered or unexported fields }
Client client to control your connection and attach callbacks
func (*Client) OnConnect ¶
func (c *Client) OnConnect(callback func())
OnConnect attach callback to when a connection has been established
func (*Client) OnNewClearchatMessage ¶
OnNewClearchatMessage attach callback to new messages such as timeouts
func (*Client) OnNewMessage ¶
OnNewMessage attach callback to new standard chat messages
func (*Client) OnNewNoticeMessage ¶
OnNewNoticeMessage attach callback to new notice message such as hosts
func (*Client) OnNewRoomstateMessage ¶
OnNewRoomstateMessage attach callback to new messages such as submode enabled
func (*Client) OnNewUnsetMessage ¶
OnNewUnsetMessage attaches callback to messages that didn't parse properly. Should only be used if you're debugging the message parsing
func (*Client) OnNewUsernoticeMessage ¶
OnNewUsernoticeMessage attach callback to new usernotice message such as sub, resub, and raids
func (*Client) OnNewUserstateMessage ¶
OnNewUserstateMessage attach callback to new userstate
func (*Client) OnNewWhisper ¶
OnNewWhisper attach callback to new whisper
func (*Client) OnPingSent ¶ added in v1.1.0
func (c *Client) OnPingSent(callback func())
OnPingSent attaches callback that's called whenever the client sends out a ping message
func (*Client) OnPongReceived ¶ added in v1.1.0
func (c *Client) OnPongReceived(callback func())
OnPongReceived attaches callback that's called whenever the client receives a pong to one of its previously sent out ping messages
func (*Client) OnUserJoin ¶
OnUserJoin attaches callback to user joins
func (*Client) OnUserPart ¶
OnUserPart attaches callback to user parts
func (*Client) SetIRCToken ¶
SetIRCToken updates the oauth token for this client used for authentication This will not cause a reconnect, but is meant more for "on next connect, use this new token" in case the old token has expired
type Message ¶
type Message struct { Type MessageType Time time.Time Action bool Emotes []*Emote Tags map[string]string Text string Raw string ChannelID string }
Message data you receive from tmi
type MessageType ¶
type MessageType int
MessageType different message types possible to receive via IRC
const ( // UNSET is the default message type, for whenever a new message type is added by twitch that we don't parse yet UNSET MessageType = -1 // WHISPER private messages WHISPER MessageType = 0 // PRIVMSG standard chat message PRIVMSG MessageType = 1 // CLEARCHAT timeout messages CLEARCHAT MessageType = 2 // ROOMSTATE changes like sub mode ROOMSTATE MessageType = 3 // USERNOTICE messages like subs, resubs, raids, etc USERNOTICE MessageType = 4 // USERSTATE messages USERSTATE MessageType = 5 // NOTICE messages like sub mode, host on NOTICE MessageType = 6 )