-
Notifications
You must be signed in to change notification settings - Fork 2
/
message.go
136 lines (116 loc) · 4.63 KB
/
message.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package revoltgo
import (
"time"
)
type (
MessageSystemType string
MessageEmbedSpecialType string
)
const (
MessageSystemTypeText MessageSystemType = "text"
MessageSystemTypeUserAdded MessageSystemType = "user_added"
MessageSystemTypeUserRemove MessageSystemType = "user_remove"
MessageSystemTypeUserJoined MessageSystemType = "user_joined"
MessageSystemTypeUserLeft MessageSystemType = "user_left"
MessageSystemTypeUserKicked MessageSystemType = "user_kicked"
MessageSystemTypeUserBanned MessageSystemType = "user_banned"
MessageSystemTypeChannelRenamed MessageSystemType = "channel_renamed"
MessageSystemTypeChannelDescriptionChanged MessageSystemType = "channel_description_changed"
MessageSystemTypeChannelIconChanged MessageSystemType = "channel_icon_changed"
MessageSystemTypeChannelOwnershipChanged MessageSystemType = "channel_ownership_changed"
)
const (
MessageEmbedSpecialTypeNone = "None"
MessageEmbedSpecialTypeGIF = "GIF"
MessageEmbedSpecialTypeYouTube = "YouTube"
MessageEmbedSpecialTypeLightspeed = "Lightspeed"
MessageEmbedSpecialTypeTwitch = "Twitch"
MessageEmbedSpecialTypeSpotify = "Spotify"
MessageEmbedSpecialTypeSoundcloud = "Soundcloud"
MessageEmbedSpecialTypeBandcamp = "Bandcamp"
MessageEmbedSpecialTypeStreamable = "Streamable"
)
// Message contains information about a message.
type Message struct {
ID string `json:"_id"`
Nonce string `json:"nonce"`
Channel string `json:"channel"`
Author string `json:"author"`
Webhook *MessageWebhook `json:"webhook"`
Content string `json:"content"`
System *MessageSystem `json:"system"`
Attachments []*Attachment `json:"attachments"`
Edited time.Time `json:"edited"`
Embeds []*MessageEmbed `json:"embeds"`
Mentions []string `json:"mentions"`
Replies []string `json:"replies"`
// Map of emoji ID to array of user ID who reacted to it
Reactions map[string][]string `json:"reactions"`
Interactions *MessageInteractions `json:"interactions"`
Masquerade *MessageMasquerade `json:"masquerade"`
}
type MessageWebhook struct {
Name string `json:"name"`
Avatar string `json:"avatar"`
}
type MessageInteractions struct {
Reactions []string `json:"reactions"`
// Whether reactions should be restricted to the given list
RestrictReactions bool `json:"restrict_reactions"`
}
type MessageSystem struct {
Type MessageSystemType `json:"type"`
ID string `json:"id"`
}
type MessageEdited struct {
Date int `json:"$date"`
}
type MessageEmbed struct {
Type string `json:"type"`
URL string `json:"url,omitempty"`
OriginalURL string `json:"original_url,omitempty"`
Special *MessageEmbedSpecial `json:"special,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Image *MessageEmbedImage `json:"image,omitempty"`
Video *MessageEmbedVideo `json:"video,omitempty"`
SiteName string `json:"site_name,omitempty"`
IconURL string `json:"icon_url,omitempty"`
Colour string `json:"colour,omitempty"`
}
type MessageEmbedSpecial struct {
Type MessageEmbedSpecialType `json:"type"`
ID string `json:"id"`
Timestamp time.Time `json:"timestamp,omitempty"`
// Identifies the type of content for types: Lightspeed, Twitch, Spotify, and Bandcamp
ContentType string `json:"content_type"`
}
type MessageEmbedImage struct {
Size string `json:"size"`
URL string `json:"url"`
Width int `json:"width"`
Height int `json:"height"`
}
type MessageEmbedVideo struct {
URL string `json:"url"`
Width int `json:"width"`
Height int `json:"height"`
}
// MessageSend is used for sending messages to channels
type MessageSend struct {
Content string `json:"content"`
Attachments []string `json:"attachments,omitempty"`
Replies []*MessageReplies `json:"replies,omitempty"`
Embeds []*MessageEmbed `json:"embeds,omitempty"`
Masquerade *MessageMasquerade `json:"masquerade,omitempty"`
Interactions *MessageInteractions `json:"interactions,omitempty"`
}
type MessageMasquerade struct {
Name string `json:"name,omitempty"`
Avatar string `json:"avatar,omitempty"`
Colour string `json:"colour,omitempty"`
}
type MessageReplies struct {
ID string `json:"id"`
Mention bool `json:"mention"`
}