Documentation ¶
Index ¶
- Constants
- func Max(values ...time.Duration) time.Duration
- type AccountsChangedEvent
- type AckErrorEvent
- type AckMessage
- type BotAddedEvent
- type BotChangedEvent
- type CommandsChangedEvent
- type ConnectedEvent
- type ConnectingEvent
- type ConnectionErrorEvent
- type DisconnectedEvent
- type EmailDomainChangedEvent
- type EmojiChangedEvent
- type Event
- type HelloEvent
- type IncomingEventError
- type InvalidAuthEvent
- type LatencyReport
- type ManualPresenceChangeEvent
- type MemberJoinedChannelEvent
- type MemberLeftChannelEvent
- type MessageTooLongEvent
- type OutgoingErrorEvent
- type Ping
- type Pong
- type PrefChangeEvent
- type RTM
- func (rtm *RTM) Disconnect() error
- func (rtm *RTM) GetInfo() *slack.Info
- func (rtm *RTM) ManageConnection()
- func (rtm *RTM) NewOutgoingMessage(text string, channelID string, options ...RTMsgOption) *slack.OutgoingMessage
- func (rtm *RTM) NewSubscribeUserPresence(ids []string) *slack.OutgoingMessage
- func (rtm *RTM) NewTypingMessage(channelID string) *slack.OutgoingMessage
- func (rtm *RTM) SendMessage(msg *slack.OutgoingMessage)
- type RTMError
- type RTMEvent
- type RTMOption
- type RTMResponse
- type RTMsgOption
- type RateLimitEvent
- type ReconnectUrlEvent
- type TypedEvent
- type UnmarshallingErrorEvent
- type UserChangeEvent
- type UserTypingEvent
Constants ¶
const ( // MaxMessageTextLength is the current maximum message length in number of characters as defined here // https://api.slack.com/rtm#limits MaxMessageTextLength = 4000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountsChangedEvent ¶
type AccountsChangedEvent struct {
Type string `json:"type"`
}
AccountsChangedEvent represents the accounts changed event
type AckErrorEvent ¶
type AckErrorEvent struct {
ErrorObj error
}
AckErrorEvent i
func (*AckErrorEvent) Error ¶
func (a *AckErrorEvent) Error() string
type AckMessage ¶
type AckMessage struct { ReplyTo int `json:"reply_to"` Timestamp string `json:"ts"` Text string `json:"text"` RTMResponse }
AckMessage is used for messages received in reply to other messages
type BotAddedEvent ¶
BotAddedEvent represents the bot added event
type BotChangedEvent ¶
BotChangedEvent represents the bot changed event
type CommandsChangedEvent ¶
type CommandsChangedEvent struct { Type string `json:"type"` EventTimestamp string `json:"event_ts"` }
CommandsChangedEvent represents the commands changed event
type ConnectedEvent ¶
type ConnectedEvent struct { ConnectionCount int // 1 = first time, 2 = second time Info *slack.Info }
ConnectedEvent is used for when we connect to Slack
type ConnectingEvent ¶
type ConnectingEvent struct { Attempt int // 1 = first attempt, 2 = second attempt ConnectionCount int }
ConnectingEvent contains information about our connection attempt
type ConnectionErrorEvent ¶
type ConnectionErrorEvent struct { Attempt int Backoff time.Duration // how long we'll wait before the next attempt ErrorObj error }
ConnectionErrorEvent contains information about a connection error
func (*ConnectionErrorEvent) Error ¶
func (c *ConnectionErrorEvent) Error() string
type DisconnectedEvent ¶
DisconnectedEvent contains information about how we disconnected
type EmailDomainChangedEvent ¶
type EmailDomainChangedEvent struct { Type string `json:"type"` EventTimestamp string `json:"event_ts"` EmailDomain string `json:"email_domain"` }
EmailDomainChangedEvent represents the email domain changed event
type EmojiChangedEvent ¶
type EmojiChangedEvent struct { Type string `json:"type"` SubType string `json:"subtype"` Name string `json:"name"` Names []string `json:"names"` Value string `json:"value"` EventTimestamp string `json:"event_ts"` }
EmojiChangedEvent represents the emoji changed event
type Event ¶
type Event struct {
Type string `json:"type,omitempty"`
}
Event contains the event type
type IncomingEventError ¶
type IncomingEventError struct {
ErrorObj error
}
IncomingEventError contains information about an unexpected error receiving a websocket event
func (*IncomingEventError) Error ¶
func (i *IncomingEventError) Error() string
type InvalidAuthEvent ¶
type InvalidAuthEvent struct{}
InvalidAuthEvent is used in case we can't even authenticate with the API
type LatencyReport ¶
LatencyReport contains information about connection latency
type ManualPresenceChangeEvent ¶
type ManualPresenceChangeEvent struct { Type string `json:"type"` Presence string `json:"presence"` }
ManualPresenceChangeEvent represents the manual presence change event
type MemberJoinedChannelEvent ¶
type MemberJoinedChannelEvent struct { Type string `json:"type"` User string `json:"user"` Channel string `json:"channel"` ChannelType string `json:"channel_type"` Team string `json:"team"` Inviter string `json:"inviter"` }
MemberJoinedChannelEvent, a user joined a public or private channel
type MemberLeftChannelEvent ¶
type MemberLeftChannelEvent struct { Type string `json:"type"` User string `json:"user"` Channel string `json:"channel"` ChannelType string `json:"channel_type"` Team string `json:"team"` }
MemberJoinedChannelEvent, a user left a public or private channel
type MessageTooLongEvent ¶
type MessageTooLongEvent struct { Message slack.OutgoingMessage MaxLength int }
MessageTooLongEvent is used when sending a message that is too long
func (*MessageTooLongEvent) Error ¶
func (m *MessageTooLongEvent) Error() string
type OutgoingErrorEvent ¶
type OutgoingErrorEvent struct { Message slack.OutgoingMessage ErrorObj error }
OutgoingErrorEvent contains information in case there were errors sending messages
func (OutgoingErrorEvent) Error ¶
func (o OutgoingErrorEvent) Error() string
type Ping ¶
type Ping struct { ID int `json:"id"` Type string `json:"type"` Timestamp int64 `json:"timestamp"` }
Ping contains information about a Ping Event
type Pong ¶
type Pong struct { Type string `json:"type"` ReplyTo int `json:"reply_to"` Timestamp int64 `json:"timestamp"` }
Pong contains information about a Pong Event
type PrefChangeEvent ¶
type PrefChangeEvent struct { Type string `json:"type"` Name string `json:"name"` Value json.RawMessage `json:"value"` }
PrefChangeEvent represents a user preferences change event
type RTM ¶
type RTM struct { // Client is the main API, embedded slack.Client IncomingEvents chan RTMEvent RawEvents chan json.RawMessage // contains filtered or unexported fields }
RTM represents a managed websocket connection. It also supports all the methods of the `Client` type.
Create this element with Client's NewRTM() or NewRTMWithOptions(*RTMOptions)
func NewRTM ¶
NewRTM returns a RTM, which provides a fully managed connection to Slack's websocket-based Real-Time Messaging protocol.
func (*RTM) Disconnect ¶
Disconnect and wait, blocking until a successful disconnection.
func (*RTM) GetInfo ¶
GetInfo returns the info structure received when calling "startrtm", holding metadata needed to implement a full chat client. It will be non-nil after a call to StartRTM().
func (*RTM) ManageConnection ¶
func (rtm *RTM) ManageConnection()
ManageConnection can be called on a Slack RTM instance returned by the NewRTM method. It will connect to the slack RTM API and handle all incoming and outgoing events. If a connection fails then it will attempt to reconnect and will notify any listeners through an error event on the IncomingEvents channel.
If the connection ends and the disconnect was unintentional then this will attempt to reconnect.
This should only be called once per slack API! Otherwise expect undefined behavior.
The defined error events are located in websocket_internals.go.
func (*RTM) NewOutgoingMessage ¶
func (rtm *RTM) NewOutgoingMessage(text string, channelID string, options ...RTMsgOption) *slack.OutgoingMessage
NewOutgoingMessage prepares an OutgoingMessage that the user can use to send a message. Use this function to properly set the messageID.
func (*RTM) NewSubscribeUserPresence ¶
func (rtm *RTM) NewSubscribeUserPresence(ids []string) *slack.OutgoingMessage
NewSubscribeUserPresence prepares an OutgoingMessage that the user can use to subscribe presence events for the specified users.
func (*RTM) NewTypingMessage ¶
func (rtm *RTM) NewTypingMessage(channelID string) *slack.OutgoingMessage
NewTypingMessage prepares an OutgoingMessage that the user can use to send as a typing indicator. Use this function to properly set the messageID.
func (*RTM) SendMessage ¶
func (rtm *RTM) SendMessage(msg *slack.OutgoingMessage)
SendMessage submits a simple message through the websocket. For more complicated messages, use `rtm.PostMessage` with a complete struct describing your attachments and all.
type RTMEvent ¶
type RTMEvent struct { Type string Data interface{} }
RTMEvent is the main wrapper. You will find all the other messages attached
type RTMOption ¶
type RTMOption func(*RTM)
RTMOption options for the managed RTM.
func RTMOptionConnParams ¶
RTMOptionConnParams installs parameters to embed into the connection URL.
func RTMOptionDialer ¶
RTMOptionDialer takes a gorilla websocket Dialer and uses it as the Dialer when opening the websocket for the RTM connection.
func RTMOptionPingInterval ¶
RTMOptionPingInterval determines how often to deliver a ping message to slack.
func RTMOptionUseStart ¶
RTMOptionUseStart as of 11th July 2017 you should prefer setting this to false, see: https://api.slack.com/changelog/2017-04-start-using-rtm-connect-and-stop-using-rtm-start
type RTMResponse ¶
RTMResponse encapsulates response details as returned by the Slack API
type RTMsgOption ¶
type RTMsgOption func(*slack.OutgoingMessage)
RTMsgOption allows configuration of various options available for sending an RTM message
func RTMsgOptionBroadcast ¶
func RTMsgOptionBroadcast() RTMsgOption
RTMsgOptionBroadcast sets broadcast reply to channel to "true"
func RTMsgOptionTS ¶
func RTMsgOptionTS(threadTimestamp string) RTMsgOption
RTMsgOptionTS sets thead timestamp of an outgoing message in order to respond to a thread
type RateLimitEvent ¶
type RateLimitEvent struct{}
RateLimitEvent is used when Slack warns that rate-limits are being hit.
func (*RateLimitEvent) Error ¶
func (e *RateLimitEvent) Error() string
type ReconnectUrlEvent ¶
ReconnectUrlEvent represents the receiving reconnect url event
type TypedEvent ¶
type TypedEvent struct {
// contains filtered or unexported fields
}
type UnmarshallingErrorEvent ¶
type UnmarshallingErrorEvent struct {
ErrorObj error
}
UnmarshallingErrorEvent is used when there are issues deconstructing a response
func (UnmarshallingErrorEvent) Error ¶
func (u UnmarshallingErrorEvent) Error() string
type UserChangeEvent ¶
UserChangeEvent represents the user change event
type UserTypingEvent ¶
type UserTypingEvent struct { Type string `json:"type"` User string `json:"user"` Channel string `json:"channel"` }
UserTypingEvent represents the user typing event