forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.go
82 lines (73 loc) · 2.33 KB
/
messages.go
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
package slack
type OutgoingMessage struct {
Id int `json:"id"`
ChannelId string `json:"channel,omitempty"`
Text string `json:"text,omitempty"`
Type string `json:"type,omitempty"`
}
// Message is an auxiliary type to allow us to have a message containing sub messages
type Message struct {
Msg
SubMessage Msg `json:"message,omitempty"`
}
// Msg contains information about a slack message
type Msg struct {
Id string `json:"id"`
BotId string `json:"bot_id,omitempty"`
UserId string `json:"user,omitempty"`
Username string `json:"username,omitempty"`
ChannelId string `json:"channel,omitempty"`
Timestamp string `json:"ts,omitempty"`
Text string `json:"text,omitempty"`
Team string `json:"team,omitempty"`
File File `json:"file,omitempty"`
// Type may come if it's part of a message list
// e.g.: channel.history
Type string `json:"type,omitempty"`
IsStarred bool `json:"is_starred,omitempty"`
// Submessage
SubType string `json:"subtype,omitempty"`
Hidden bool `json:"bool,omitempty"`
DeletedTimestamp string `json:"deleted_ts,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
ReplyTo int `json:"reply_to,omitempty"`
Upload bool `json:"upload,omitempty"`
}
// Presence XXX: not used yet
type Presence struct {
Presence string `json:"presence"`
UserId string `json:"user"`
}
// Event contains the event type
type Event struct {
Type string `json:"type,omitempty"`
}
// Ping contains information about a Ping Event
type Ping struct {
Id int `json:"id"`
Type string `json:"type"`
}
// Pong contains information about a Pong Event
type Pong struct {
Type string `json:"type"`
ReplyTo int `json:"reply_to"`
}
// AckMessage is used for messages received in reply to other messages
type AckMessage struct {
ReplyTo int `json:"reply_to"`
Timestamp string `json:"ts"`
Text string `json:"text"`
SlackResponse
}
// NewOutGoingMessage prepares an OutgoingMessage that the user can use to send a message
func (api *SlackWS) NewOutgoingMessage(text string, channel string) *OutgoingMessage {
api.mutex.Lock()
defer api.mutex.Unlock()
api.messageId++
return &OutgoingMessage{
Id: api.messageId,
Type: "message",
ChannelId: channel,
Text: text,
}
}