Documentation
¶
Index ¶
- Constants
- Variables
- type ClearChatMessage
- type ClearMessage
- type Client
- func (c *Client) ClearMsg(channel, text string)
- func (c *Client) Connect() error
- func (c *Client) Depart(channel string)
- func (c *Client) Disconnect() error
- func (c *Client) Join(channels ...string)
- func (c *Client) OnClearChatMessage(callback func(message ClearChatMessage))
- func (c *Client) OnClearMessage(callback func(message ClearMessage))
- func (c *Client) OnConnect(callback func())
- func (c *Client) OnNamesMessage(callback func(message NamesMessage))
- func (c *Client) OnNoticeMessage(callback func(message NoticeMessage))
- func (c *Client) OnPingMessage(callback func(message PingMessage))
- func (c *Client) OnPingSent(callback func())
- func (c *Client) OnPongMessage(callback func(message PongMessage))
- func (c *Client) OnPrivateMessage(callback func(message PrivateMessage))
- func (c *Client) OnReconnectMessage(callback func(message ReconnectMessage))
- func (c *Client) OnRoomStateMessage(callback func(message RoomStateMessage))
- func (c *Client) OnUnsetMessage(callback func(message RawMessage))
- func (c *Client) OnUserJoinMessage(callback func(message UserJoinMessage))
- func (c *Client) OnUserNoticeMessage(callback func(message UserNoticeMessage))
- func (c *Client) OnUserPartMessage(callback func(message UserPartMessage))
- func (c *Client) OnUserStateMessage(callback func(message UserStateMessage))
- func (c *Client) OnWhisperMessage(callback func(message WhisperMessage))
- 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 NamesMessage
- type NoticeMessage
- type PingMessage
- type PongMessage
- type PrivateMessage
- type RawMessage
- type ReconnectMessage
- type RoomStateMessage
- type User
- type UserJoinMessage
- type UserNoticeMessage
- type UserPartMessage
- type UserStateMessage
- type WhisperMessage
Constants ¶
const ( // TagsCapability for Twitch's Tags capabilities, see https://dev.twitch.tv/docs/irc/tags TagsCapability = "twitch.tv/tags" // CommandsCapability for Twitch's Commands capabilities, see https://dev.twitch.tv/docs/irc/commands CommandsCapability = "twitch.tv/commands" // MembershipCapability for Twitch's Membership capabilities, see https://dev.twitch.tv/docs/irc/membership MembershipCapability = "twitch.tv/membership" )
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 // DefaultCapabilities is the default caps when creating a new Client DefaultCapabilities = []string{TagsCapability, CommandsCapability, MembershipCapability} )
Functions ¶
This section is empty.
Types ¶
type ClearChatMessage ¶
type ClearChatMessage struct { Raw string Type MessageType RawType string Tags map[string]string Message string Channel string RoomID string Time time.Time BanDuration int TargetUserID string TargetUsername string }
ClearChatMessage data you receive from CLEARCHAT message type
func (*ClearChatMessage) GetType ¶
func (msg *ClearChatMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type ClearMessage ¶
type ClearMessage struct { Raw string Type MessageType RawType string Tags map[string]string Message string Channel string Login string TargetMsgID string }
ClearMessage data you receive from CLEARMSG message type
func (*ClearMessage) GetType ¶
func (msg *ClearMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
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 // Capabilities is the list of capabilities that should be sent as part of the connection setup // By default, this is all caps (Tags, Commands, Membership) // If this is an empty list or nil, no CAP REQ message is sent at all Capabilities []string // contains filtered or unexported fields }
Client client to control your connection and attach callbacks
func NewAnonymousClient ¶
func NewAnonymousClient() *Client
NewAnonymousClient to create a new client without login requirements (anonymous user) Do note that the Say and Whisper functions will be ineffectual when using this constructor
func (*Client) OnClearChatMessage ¶
func (c *Client) OnClearChatMessage(callback func(message ClearChatMessage))
OnClearChatMessage attach callback to new messages such as timeouts
func (*Client) OnClearMessage ¶
func (c *Client) OnClearMessage(callback func(message ClearMessage))
OnClearMessage attach callback when a single message is deleted
func (*Client) OnConnect ¶
func (c *Client) OnConnect(callback func())
OnConnect attach callback to when a connection has been established
func (*Client) OnNamesMessage ¶
func (c *Client) OnNamesMessage(callback func(message NamesMessage))
OnNamesMessage attaches callback to /names response
func (*Client) OnNoticeMessage ¶
func (c *Client) OnNoticeMessage(callback func(message NoticeMessage))
OnNoticeMessage attach callback to new notice message such as hosts
func (*Client) OnPingMessage ¶
func (c *Client) OnPingMessage(callback func(message PingMessage))
OnPingMessage attaches callback to PING message
func (*Client) OnPingSent ¶
func (c *Client) OnPingSent(callback func())
OnPingSent attaches callback that's called whenever the client sends out a ping message
func (*Client) OnPongMessage ¶
func (c *Client) OnPongMessage(callback func(message PongMessage))
OnPongMessage attaches callback to PONG message
func (*Client) OnPrivateMessage ¶
func (c *Client) OnPrivateMessage(callback func(message PrivateMessage))
OnPrivateMessage attach callback to new standard chat messages
func (*Client) OnReconnectMessage ¶
func (c *Client) OnReconnectMessage(callback func(message ReconnectMessage))
OnReconnectMessage attaches callback that is triggered whenever the twitch servers tell us to reconnect
func (*Client) OnRoomStateMessage ¶
func (c *Client) OnRoomStateMessage(callback func(message RoomStateMessage))
OnRoomStateMessage attach callback to new messages such as submode enabled
func (*Client) OnUnsetMessage ¶
func (c *Client) OnUnsetMessage(callback func(message RawMessage))
OnUnsetMessage attaches callback to message types we currently don't support
func (*Client) OnUserJoinMessage ¶
func (c *Client) OnUserJoinMessage(callback func(message UserJoinMessage))
OnUserJoinMessage attaches callback to user joins
func (*Client) OnUserNoticeMessage ¶
func (c *Client) OnUserNoticeMessage(callback func(message UserNoticeMessage))
OnUserNoticeMessage attach callback to new usernotice message such as sub, resub, and raids
func (*Client) OnUserPartMessage ¶
func (c *Client) OnUserPartMessage(callback func(message UserPartMessage))
OnUserPartMessage attaches callback to user parts
func (*Client) OnUserStateMessage ¶
func (c *Client) OnUserStateMessage(callback func(message UserStateMessage))
OnUserStateMessage attach callback to new userstate
func (*Client) OnWhisperMessage ¶
func (c *Client) OnWhisperMessage(callback func(message WhisperMessage))
OnWhisperMessage attach callback to new whisper
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 interface {
GetType() MessageType
}
Message interface that all messages implement
func ParseMessage ¶
ParseMessage parse a raw Twitch IRC message
type MessageType ¶
type MessageType int
MessageType different message types possible to receive via IRC
const ( // UNSET is for message types we currently don't support 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 // JOIN whenever a user joins a channel JOIN MessageType = 7 // PART whenever a user parts from a channel PART MessageType = 8 // RECONNECT is sent from Twitch when they request the client to reconnect (i.e. for an irc server restart) // https://dev.twitch.tv/docs/irc/commands/#reconnect-twitch-commands RECONNECT MessageType = 9 // NAMES (or 353 https://www.alien.net.au/irc/irc2numerics.html#353) is the response sent from the server when // the client requests a list of names for a channel NAMES MessageType = 10 // PING is a message that can be sent from the IRC server. go-twitch-irc responds to PINGs automatically PING MessageType = 11 // PONG is a message that should be sent from the IRC server as a response to us sending a PING message. PONG MessageType = 12 // CLEARMSG whenever a single message is deleted CLEARMSG MessageType = 13 )
type NamesMessage ¶
type NamesMessage struct { Raw string Type MessageType RawType string // Channel name Channel string // List of user names Users []string }
NamesMessage describes the data posted in response to a /names command See https://www.alien.net.au/irc/irc2numerics.html#353
func (*NamesMessage) GetType ¶
func (msg *NamesMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type NoticeMessage ¶
type NoticeMessage struct { Raw string Type MessageType RawType string Tags map[string]string Message string Channel string MsgID string }
NoticeMessage data you receive from the NOTICE message type
func (*NoticeMessage) GetType ¶
func (msg *NoticeMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type PingMessage ¶
type PingMessage struct { Raw string Type MessageType RawType string Message string }
PingMessage describes an IRC PING message
func (*PingMessage) GetType ¶
func (msg *PingMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type PongMessage ¶
type PongMessage struct { Raw string Type MessageType RawType string Message string }
PongMessage describes an IRC PONG message
func (*PongMessage) GetType ¶
func (msg *PongMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type PrivateMessage ¶
type PrivateMessage struct { User User Raw string Type MessageType RawType string Tags map[string]string Message string Channel string RoomID string ID string Time time.Time Emotes []*Emote Bits int Action bool }
PrivateMessage data you receive from PRIVMSG message type
func (*PrivateMessage) GetType ¶
func (msg *PrivateMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type RawMessage ¶
type RawMessage struct { Raw string Type MessageType RawType string Tags map[string]string Message string }
RawMessage data you receive from TMI
func (*RawMessage) GetType ¶
func (msg *RawMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type ReconnectMessage ¶
type ReconnectMessage struct { Raw string Type MessageType RawType string }
ReconnectMessage describes the
func (*ReconnectMessage) GetType ¶
func (msg *ReconnectMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type RoomStateMessage ¶
type RoomStateMessage struct { Raw string Type MessageType RawType string Tags map[string]string Message string Channel string RoomID string State map[string]int }
RoomStateMessage data you receive from ROOMSTATE message type
func (*RoomStateMessage) GetType ¶
func (msg *RoomStateMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type UserJoinMessage ¶
type UserJoinMessage struct { Raw string Type MessageType RawType string // Channel name Channel string // User name User string }
UserJoinMessage desJoines the message that is sent whenever a user joins a channel we're connected to See https://dev.twitch.tv/docs/irc/membership/#join-twitch-membership
func (*UserJoinMessage) GetType ¶
func (msg *UserJoinMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type UserNoticeMessage ¶
type UserNoticeMessage struct { User User Raw string Type MessageType RawType string Tags map[string]string Message string Channel string RoomID string ID string Time time.Time Emotes []*Emote MsgID string MsgParams map[string]string SystemMsg string }
UserNoticeMessage data you receive from USERNOTICE message type
func (*UserNoticeMessage) GetType ¶
func (msg *UserNoticeMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type UserPartMessage ¶
type UserPartMessage struct { Raw string Type MessageType RawType string // Channel name Channel string // User name User string }
UserPartMessage describes the message that is sent whenever a user leaves a channel we're connected to See https://dev.twitch.tv/docs/irc/membership/#part-twitch-membership
func (*UserPartMessage) GetType ¶
func (msg *UserPartMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type UserStateMessage ¶
type UserStateMessage struct { User User Raw string Type MessageType RawType string Tags map[string]string Message string Channel string EmoteSets []string }
UserStateMessage data you receive from the USERSTATE message type
func (*UserStateMessage) GetType ¶
func (msg *UserStateMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type
type WhisperMessage ¶
type WhisperMessage struct { User User Raw string Type MessageType RawType string Tags map[string]string Message string Target string MessageID string ThreadID string Emotes []*Emote Action bool }
WhisperMessage data you receive from WHISPER message type
func (*WhisperMessage) GetType ¶
func (msg *WhisperMessage) GetType() MessageType
GetType implements the Message interface, and returns this message's type