blob: 3e1906eee919afe32d25bf522df6c28d994341f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
package slack
import (
"fmt"
"time"
)
/**
* Internal events, created by this lib and not mapped to Slack APIs.
*/
// ConnectedEvent is used for when we connect to Slack
type ConnectedEvent struct {
ConnectionCount int // 1 = first time, 2 = second time
Info *Info
}
// ConnectionErrorEvent contains information about a connection error
type ConnectionErrorEvent struct {
Attempt int
Backoff time.Duration // how long we'll wait before the next attempt
ErrorObj error
}
func (c *ConnectionErrorEvent) Error() string {
return c.ErrorObj.Error()
}
// ConnectingEvent contains information about our connection attempt
type ConnectingEvent struct {
Attempt int // 1 = first attempt, 2 = second attempt
ConnectionCount int
}
// DisconnectedEvent contains information about how we disconnected
type DisconnectedEvent struct {
Intentional bool
Cause error
}
// LatencyReport contains information about connection latency
type LatencyReport struct {
Value time.Duration
}
// InvalidAuthEvent is used in case we can't even authenticate with the API
type InvalidAuthEvent struct{}
// UnmarshallingErrorEvent is used when there are issues deconstructing a response
type UnmarshallingErrorEvent struct {
ErrorObj error
}
func (u UnmarshallingErrorEvent) Error() string {
return u.ErrorObj.Error()
}
// MessageTooLongEvent is used when sending a message that is too long
type MessageTooLongEvent struct {
Message OutgoingMessage
MaxLength int
}
func (m *MessageTooLongEvent) Error() string {
return fmt.Sprintf("Message too long (max %d characters)", m.MaxLength)
}
// RateLimitEvent is used when Slack warns that rate-limits are being hit.
type RateLimitEvent struct{}
func (e *RateLimitEvent) Error() string {
return "Messages are being sent too fast."
}
// OutgoingErrorEvent contains information in case there were errors sending messages
type OutgoingErrorEvent struct {
Message OutgoingMessage
ErrorObj error
}
func (o OutgoingErrorEvent) Error() string {
return o.ErrorObj.Error()
}
// IncomingEventError contains information about an unexpected error receiving a websocket event
type IncomingEventError struct {
ErrorObj error
}
func (i *IncomingEventError) Error() string {
return i.ErrorObj.Error()
}
// AckErrorEvent i
type AckErrorEvent struct {
ErrorObj error
}
func (a *AckErrorEvent) Error() string {
return a.ErrorObj.Error()
}
|