-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.go
170 lines (126 loc) · 5.24 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package guildedgo
// ChatMessage is the default message struct
type ChatMessage struct {
// The ID of the message
ID string `json:"id"`
// The type of chat message.
// "system" messages are generated by Guilded, while "default" messages are user or bot-generated.
Type string `json:"type,omitempty"`
// The ID of the server
ServerID string `json:"serverId,omitempty"`
GroupID string `json:"groupId,omitempty"`
// The ID of the channel
ChannelID string `json:"channelId"`
// The content of the message
Content string `json:"content,omitempty"`
// Embeds for the message.
//
// (min items 1; max items 10
Embeds []ChatEmbed `json:"embeds,omitempty"`
// Message IDs that were replied to
ReplyMessageIds []string `json:"replyMessageIds,omitempty"`
// If set, this message will only be seen by those mentioned or replied to.
IsPrivate bool `json:"isPrivate,omitempty"`
// If set, this message did not notify mention or reply recipients (default false)
IsSilent bool `json:"isSilent,omitempty"`
Mentions `json:"mentions,omitempty"`
// The ISO 8601 timestamp that the message was created at.
CreatedAt string `json:"createdAt"`
// The ID for the user who created this messsage
// (Note: if this event has `createdByWebhookId` present,
// this field will still be populated, but can be ignored.
// In this case, the value of this field will always be Ann6LewA)
CreatedBy string `json:"createdBy"`
// The ID of the webhook who created this message, if was created by a webhook
CreatedByWebhookId string `json:"createdByWebhookId,omitempty"`
// The IOSO 8601 timestamp that the message was updated at, if relevant
UpdatedAt string `json:"updatedAt,omitempty"`
}
const (
ChatMessageTypeDefault string = "default"
ChatMessageTypeSystem string = "system"
)
// ChatEmbed are rich content sections optionally associated with chat messages.
// Properties with "webhook-markdown" support allow for the following: link, italic,
// bold, strikethrough, underline, inline code, block code, reaction, and mention.
type ChatEmbed struct {
// Main header of the embed (max length 256)
Title string `json:"embed,omitempty"`
// Subtext of the embed (max length 2048)
Description string `json:"description,omitempty"`
// URL to linkify the title field with (max length 1024; regex ^(?!attachment))
URL string `json:"url,omitempty"`
// Decimal value of the color that the left border should be (min 0; max 16777215)
Color int `json:"color,omitempty"`
// A small section at the bottom of the embed
Footer ChatEmbedFooter `json:"footer,omitempty"`
// A timestamp to put in the footer
Timestamp string `json:"timestamp,omitempty"`
// An image to the right of the embed's content
Thumbnail ChatEmbedThumbnail `json:"thumbnail,omitempty"`
// The main picture to associate with the embed
Image ChatEmbedImage `json:"image"`
// A small section above the title of the embed
Author ChatEmbedAuthor `json:"author,omitempty"`
// Table-like cells to add to the embed (max items 25)
Fields []ChatEmbedField `json:"fields,omitempty"`
}
type ChatEmbedFooter struct {
// URL of a small image to put in the footer (max length 1024)
IconURL string `json:"icon_url,omitempty"`
// Text of the footer (max length 2048)
Text string `json:"text"`
}
type ChatEmbedThumbnail struct {
// URL of the image (max length 1024)
URL string `json:"url,omitempty"`
}
type ChatEmbedImage struct {
// URL of the image (max length 1024)
URL string `json:"url,omitempty"`
}
type ChatEmbedAuthor struct {
// Name of the author (max length 256)
Name string `jsojn:"name,omitempty"`
// URL to linkify the author's name field (max length 1024; regex ^(?!attachment))
URL string `json:"url,omitempty"`
// URL of a small image to display to the left of the author's name (max length 1024
IconURL string `json:"icon_url,omitempty"`
}
type ChatEmbedField struct {
// Header of the table-like cell (max length 256)
Name string `json:"name"`
// Subtext of the table-like cell (max length 1024)
Value string `json:"value"`
// If the field should wrap or not (default false)
Inline bool `json:"inline,omitempty"`
}
type MessageObject struct {
// If set, this message will only be seen by those mentioned or replied to
IsPrivate bool `json:"isPrivate,omitempty"`
// If set, this message will not notify any mentioned users or roles (default false)
IsSilent bool `json:"isSilent,omitempty"`
// Message IDs to reply to (min items 1; max items 5)
ReplyMessageIds []string `json:"replyMessageIds,omitempty"`
// The content of the message (min length 1; max length 4000)
Content string `json:"content,omitempty"`
// At this time, only one embed is supported per message, and attachments are not supported.
// If you need to send more than one embed or upload attachments, consider creating the
// message via a webhook. (min items 1; max items 1)
Embeds []ChatEmbed `json:"embeds,omitempty"`
}
type MessageResponse struct {
Message ChatMessage `json:"message"`
}
type GetMessageResponse struct {
Message ChatMessage `json:"message"`
}
type GetMessagesObject struct {
Before string `json:"before"`
After string `json:"after"`
Limit int `json:"limit"`
IncludePrivate bool `json:"includePrivate"`
}
type AllMessagesResponse struct {
Messages []ChatMessage `json:"messages"`
}