1package slack
2
3import (
4	"encoding/json"
5	"fmt"
6)
7
8// AckMessage is used for messages received in reply to other messages
9type AckMessage struct {
10	ReplyTo   int    `json:"reply_to"`
11	Timestamp string `json:"ts"`
12	Text      string `json:"text"`
13	RTMResponse
14}
15
16// RTMResponse encapsulates response details as returned by the Slack API
17type RTMResponse struct {
18	Ok    bool      `json:"ok"`
19	Error *RTMError `json:"error"`
20}
21
22// RTMError encapsulates error information as returned by the Slack API
23type RTMError struct {
24	Code int
25	Msg  string
26}
27
28func (s RTMError) Error() string {
29	return fmt.Sprintf("Code %d - %s", s.Code, s.Msg)
30}
31
32// MessageEvent represents a Slack Message (used as the event type for an incoming message)
33type MessageEvent Message
34
35// RTMEvent is the main wrapper. You will find all the other messages attached
36type RTMEvent struct {
37	Type string
38	Data interface{}
39}
40
41// HelloEvent represents the hello event
42type HelloEvent struct{}
43
44// PresenceChangeEvent represents the presence change event
45type PresenceChangeEvent struct {
46	Type     string `json:"type"`
47	Presence string `json:"presence"`
48	User     string `json:"user"`
49}
50
51// UserTypingEvent represents the user typing event
52type UserTypingEvent struct {
53	Type    string `json:"type"`
54	User    string `json:"user"`
55	Channel string `json:"channel"`
56}
57
58// PrefChangeEvent represents a user preferences change event
59type PrefChangeEvent struct {
60	Type  string          `json:"type"`
61	Name  string          `json:"name"`
62	Value json.RawMessage `json:"value"`
63}
64
65// ManualPresenceChangeEvent represents the manual presence change event
66type ManualPresenceChangeEvent struct {
67	Type     string `json:"type"`
68	Presence string `json:"presence"`
69}
70
71// UserChangeEvent represents the user change event
72type UserChangeEvent struct {
73	Type string `json:"type"`
74	User User   `json:"user"`
75}
76
77// EmojiChangedEvent represents the emoji changed event
78type EmojiChangedEvent struct {
79	Type           string   `json:"type"`
80	SubType        string   `json:"subtype"`
81	Name           string   `json:"name"`
82	Names          []string `json:"names"`
83	Value          string   `json:"value"`
84	EventTimestamp string   `json:"event_ts"`
85}
86
87// CommandsChangedEvent represents the commands changed event
88type CommandsChangedEvent struct {
89	Type           string `json:"type"`
90	EventTimestamp string `json:"event_ts"`
91}
92
93// EmailDomainChangedEvent represents the email domain changed event
94type EmailDomainChangedEvent struct {
95	Type           string `json:"type"`
96	EventTimestamp string `json:"event_ts"`
97	EmailDomain    string `json:"email_domain"`
98}
99
100// BotAddedEvent represents the bot added event
101type BotAddedEvent struct {
102	Type string `json:"type"`
103	Bot  Bot    `json:"bot"`
104}
105
106// BotChangedEvent represents the bot changed event
107type BotChangedEvent struct {
108	Type string `json:"type"`
109	Bot  Bot    `json:"bot"`
110}
111
112// AccountsChangedEvent represents the accounts changed event
113type AccountsChangedEvent struct {
114	Type string `json:"type"`
115}
116
117// ReconnectUrlEvent represents the receiving reconnect url event
118type ReconnectUrlEvent struct {
119	Type string `json:"type"`
120	URL  string `json:"url"`
121}
122
123// MemberJoinedChannelEvent, a user joined a public or private channel
124type MemberJoinedChannelEvent struct {
125	Type        string `json:"type"`
126	User        string `json:"user"`
127	Channel     string `json:"channel"`
128	ChannelType string `json:"channel_type"`
129	Team        string `json:"team"`
130	Inviter     string `json:"inviter"`
131}
132
133// MemberJoinedChannelEvent, a user left a public or private channel
134type MemberLeftChannelEvent struct {
135	Type        string `json:"type"`
136	User        string `json:"user"`
137	Channel     string `json:"channel"`
138	ChannelType string `json:"channel_type"`
139	Team        string `json:"team"`
140}
141