forked from shomali11/slacker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
message_event.go
56 lines (44 loc) · 1.64 KB
/
message_event.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
package slacker
// MessageEvent contains details common to message based events, including the
// raw event as returned from Slack along with the corresponding event type.
// The struct should be kept minimal and only include data that is commonly
// used to prevent frequent type assertions when evaluating the event.
type MessageEvent struct {
// Channel ID where the message was sent
Channel string
// ChannelName where the message was sent
ChannelName string
// User ID of the sender
User string
// UserName of the the sender
UserName string
// Text is the unalterted text of the message, as returned by Slack
Text string
// TimeStamp is the message timestamp. For events that do not support
// threading (eg. slash commands) this will be unset.
// will be left unset.
TimeStamp string
// ThreadTimeStamp is the message thread timestamp. For events that do not
// support threading (eg. slash commands) this will be unset.
ThreadTimeStamp string
// Data is the raw event data returned from slack. Using Type, you can assert
// this into a slackevents *Event struct.
Data interface{}
// Type is the type of the event, as returned by Slack. For instance,
// `app_mention` or `message`
Type string
// BotID of the bot that sent this message. If a bot did not send this
// message, this will be an empty string.
BotID string
}
// IsThread indicates if a message event took place in a thread.
func (e *MessageEvent) IsThread() bool {
if e.ThreadTimeStamp == "" || e.ThreadTimeStamp == e.TimeStamp {
return false
}
return true
}
// IsBot indicates if the message was sent by a bot
func (e *MessageEvent) IsBot() bool {
return e.BotID != ""
}