Documentation
¶
Overview ¶
Package dggchat provides destiny gg chat binding for Go
Index ¶
- Constants
- Variables
- type Ban
- type Broadcast
- type Donation
- type Message
- type Mute
- type Names
- type Pin
- type Ping
- type PrivateMessage
- type RoomAction
- type Session
- func (s *Session) AddBanHandler(fn func(Ban, *Session))
- func (s *Session) AddBroadcastHandler(fn func(Broadcast, *Session))
- func (s *Session) AddDonationHandler(fn func(Donation, *Session))
- func (s *Session) AddErrorHandler(fn func(string, *Session))
- func (s *Session) AddJoinHandler(fn func(RoomAction, *Session))
- func (s *Session) AddMessageHandler(fn func(Message, *Session))
- func (s *Session) AddMuteHandler(fn func(Mute, *Session))
- func (s *Session) AddNamesHandler(fn func(Names, *Session))
- func (s *Session) AddPMHandler(fn func(PrivateMessage, *Session))
- func (s *Session) AddPinHandler(fn func(Pin, *Session))
- func (s *Session) AddPingHandler(fn func(Ping, *Session))
- func (s *Session) AddQuitHandler(fn func(RoomAction, *Session))
- func (s *Session) AddSocketErrorHandler(fn func(error, *Session))
- func (s *Session) AddSubOnlyHandler(fn func(SubOnly, *Session))
- func (s *Session) AddSubscriptionHandler(fn func(Subscription, *Session))
- func (s *Session) AddUnbanHandler(fn func(Ban, *Session))
- func (s *Session) AddUnmuteHandler(fn func(Mute, *Session))
- func (s *Session) AddUserUpdateHandler(fn func(User, *Session))
- func (s *Session) Close() error
- func (s *Session) GetUser(name string) (User, bool)
- func (s *Session) GetUsers() []User
- func (s *Session) Open() error
- func (s *Session) SendAction(message string) error
- func (s *Session) SendBan(nick string, reason string, duration time.Duration, banip bool) error
- func (s *Session) SendBroadcast(message string) error
- func (s *Session) SendMessage(message string) error
- func (s *Session) SendMute(nick string, duration time.Duration) error
- func (s *Session) SendPermanentBan(nick string, reason string, banip bool) error
- func (s *Session) SendPing() error
- func (s *Session) SendPrivateMessage(nick string, message string) error
- func (s *Session) SendSubOnly(subonly bool) error
- func (s *Session) SendUnban(nick string) error
- func (s *Session) SendUnmute(nick string) error
- func (s *Session) SetDialer(d websocket.Dialer)
- func (s *Session) SetURL(u url.URL)
- type SubOnly
- type SubTier
- type Subscription
- type User
Constants ¶
const ( FeatureSubscriber = "subscriber" FeatureBot = "bot" FeatureProtected = "protected" FeatureVIP = "vip" FeatureModerator = "moderator" FeatureAdministrator = "admin" FeatureTier2 = "flair1" FeatureNotable = "flair2" FeatureTier3 = "flair3" FeatureTrusted = "flair4" FeatureContributor = "flair5" FeatureCompChallenge = "flair6" FeatureEve = "flair7" FeatureTier4 = "flair8" FeatureTwitch = "flair9" FeatureSC2 = "flair10" FeatureBot2 = "flair11" FeatureBroadcaster = "flair12" FeatureTier1 = "flair13" FeatureBirthday = "flair15" )
Constants for different types of features a user can have
const ( ErrorTooManyConnections = "toomanyconnections" ErrorProtocol = "protocolerror" ErrorNeedLogin = "needlogin" ErrorNoPermission = "nopermission" ErrorInvalidMessage = "invalidmsg" ErrorMuted = "muted" ErrorSubMode = "submode" ErrorThorttled = "throttled" ErrorDuplicate = "duplicate" ErrorNotFound = "notfound" ErrorNeedBanReason = "needbanreason" )
Constants for different types of errors the chat can return
Variables ¶
var ErrAlreadyOpen = errors.New("web socket is already open")
ErrAlreadyOpen is thrown when attempting to open a web socket connection on a websocket that is already open.
var ErrReadOnly = errors.New("session is read-only")
ErrReadOnly is thrown when attempting to send messages using a read-only session.
var ErrTooManyArgs = errors.New("function called with unexcepted amount of arguments")
ErrTooManyArgs is thrown when a funcion is called with an unexpeted number of arguments
Functions ¶
This section is empty.
Types ¶
type Ban ¶
type Ban struct { Sender User Timestamp time.Time Target User // Online indicates whether the target was online when targeted Online bool }
Ban represents (un)bans issued by chat moderators
type Broadcast ¶
type Broadcast struct { Sender User Timestamp time.Time Message string `json:"data"` UUID string `json:"uuid"` }
Broadcast represents a chat broadcast
type Mute ¶
type Mute struct { Sender User Timestamp time.Time Target User // Online indicates whether the target was online when targeted Online bool }
Mute represents (un)mutes issued by chat moderators
type Ping ¶
type Ping struct {
Timestamp int64 `json:"timestamp"`
}
Ping represents a pong response from the server
type PrivateMessage ¶
PrivateMessage represents a received private message from a user
type RoomAction ¶
RoomAction represents a user joining or quitting the chat
type Session ¶
A Session represents a connection to destinygg chat.
func New ¶
New creates a new destinygg session. Accepts either 0 or 1 arguments. If no login key is provided, a read-only session is returned
func (*Session) AddBanHandler ¶
AddBanHandler adds a function that will be called every time a ban message is received
func (*Session) AddBroadcastHandler ¶
AddBroadcastHandler adds a function that will be called every time a broadcast is sent to the chat
func (*Session) AddDonationHandler ¶
AddDonationHandler adds a function that will be called every time a donation message is received
func (*Session) AddErrorHandler ¶
AddErrorHandler adds a function that will be called every time an error message is received
func (*Session) AddJoinHandler ¶
func (s *Session) AddJoinHandler(fn func(RoomAction, *Session))
AddJoinHandler adds a function that will be called every time a user join the chat
func (*Session) AddMessageHandler ¶
AddMessageHandler adds a function that will be called every time a message is received
func (*Session) AddMuteHandler ¶
AddMuteHandler adds a function that will be called every time a mute message is received
func (*Session) AddNamesHandler ¶
AddNamesHandler adds a function that will be called every time a names message is received
func (*Session) AddPMHandler ¶
func (s *Session) AddPMHandler(fn func(PrivateMessage, *Session))
AddPMHandler adds a function that will be called every time a private message is received
func (*Session) AddPinHandler ¶
AddPinHandler adds a function that will be called every time a pin message is received
func (*Session) AddPingHandler ¶
AddPingHandler adds a function that will be called when a server responds with a pong
func (*Session) AddQuitHandler ¶
func (s *Session) AddQuitHandler(fn func(RoomAction, *Session))
AddQuitHandler adds a function that will be called every time a user quits the chat
func (*Session) AddSocketErrorHandler ¶
AddSocketErrorHandler adds a function that will be called every time a socket error occurs
func (*Session) AddSubOnlyHandler ¶
AddSubOnlyHandler adds a function that will will be called every time a subonly message is received
func (*Session) AddSubscriptionHandler ¶
func (s *Session) AddSubscriptionHandler(fn func(Subscription, *Session))
AddSubscriptionHandler adds a function that will be called every time a (regular, gifted, or a mass gift) subscription message is received
func (*Session) AddUnbanHandler ¶
AddUnbanHandler adds a function that will be called every time an unban message is received
func (*Session) AddUnmuteHandler ¶
AddUnmuteHandler adds a function that will be called every time an unmute message is received
func (*Session) AddUserUpdateHandler ¶
AddUserUpdateHandler adds a function that will be called every time user's information gets updated
func (*Session) GetUser ¶
GetUser attempts to find the user in the chat room state. If the user is found, returns the user and true, otherwise false is returned as the second parameter.
func (*Session) SendAction ¶
SendAction calls the SendMessage method but also adds "/me" in front of the message to make it a chat action same caveat with the returned error value applies.
func (*Session) SendBan ¶
SendBan bans the user with the given nick. Bans require a ban reason to be specified. If duration is <= 0, the server uses its built-in default duration
func (*Session) SendBroadcast ¶
SendBroadcast sends a broadcast message to chat
func (*Session) SendMessage ¶
SendMessage sends the given string as a message to chat. Note: a return error of nil does not guarantee successful delivery. Monitor for error events to ensure the message was sent with no errors.
func (*Session) SendMute ¶
SendMute mutes the user with the given nick. If duration is <= 0, the server uses its built-in default duration
func (*Session) SendPermanentBan ¶
SendPermanentBan bans the user with the given nick permanently. Bans require a ban reason to be specified.
func (*Session) SendPrivateMessage ¶
SendPrivateMessage sends the given user a private message.
func (*Session) SendSubOnly ¶
SendSubOnly modifies the chat subonly mode. During subonly mode, only subscribers and some other special user classes are allowed to send messages.
func (*Session) SendUnban ¶
SendUnban unbans the user with the given nick. Unbanning also removes mutes.
func (*Session) SendUnmute ¶
SendUnmute unmutes the user with the given nick.
type SubOnly ¶
SubOnly represents a subonly message from the server if active, only subscribers and some other special user classes are allowed to send messages, until another SubOnly message is received with active set to false
type Subscription ¶
type Subscription struct { Sender User Recipient User Timestamp time.Time Message string Tier SubTier Quantity int64 UUID string }
Subscription represents a dgg subscription message
func (*Subscription) IsGift ¶
func (s *Subscription) IsGift() bool
IsGift returns true if the subscription was a gift
func (*Subscription) IsMassGift ¶
func (s *Subscription) IsMassGift() bool
IsMassGift returns true if the subscription was a mass gift
type User ¶
type User struct { ID int64 `json:"id"` Nick string `json:"nick"` Features []string `json:"features"` CreatedDate time.Time `json:"createdDate"` Watching watching `json:"watching"` }
User represents a user with a list of features
func (*User) HasFeature ¶
HasFeature returns true if user has given feature