-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.go
268 lines (188 loc) · 8.28 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package tdproto
type Mediatype string
const (
MediatypePlain Mediatype = "plain"
MediatypeChange Mediatype = "change"
MediatypeDeleted Mediatype = "deleted"
MediatypeFile Mediatype = "file"
MediatypeImage Mediatype = "image"
MediatypeVideo Mediatype = "video"
MediatypeAudiomsg Mediatype = "audiomsg"
MediatypeContact Mediatype = "contact"
MediatypePdf Mediatype = "pdf"
)
type Mediasubtype string
const (
MediaSubtypeSticker Mediasubtype = "sticker"
MediaSubtypeNewtask Mediasubtype = "newtask"
MediaSubtypeNamed Mediasubtype = "named"
)
// Chat message content
type MessageContent struct {
// Text representation of message
Text string `json:"text"`
// Message type
Type Mediatype `json:"type"`
// Message subtype, if any
Subtype Mediasubtype `json:"subtype,omitempty"`
// Upload id, if any. Deprecated: use Uploads instead
Upload string `mediatype:"audiomsg,image,video,file" json:"upload,omitempty"`
// Upload url, if any. Deprecated: use Uploads instead
MediaUrl string `mediatype:"audiomsg,image,video,file" json:"mediaURL,omitempty"`
// Upload size, if any. Deprecated: use Uploads instead
Size int `mediatype:"audiomsg,image,video,file" json:"size,omitempty"`
// Upload duration, if any. Deprecated: use Uploads instead
Duration *uint `mediatype:"audiomsg,video" json:"duration,omitempty"`
// Upload still processing, if any. Deprecated: use Uploads instead
Processing bool `mediatype:"video" json:"processing,omitempty"`
// Compact representation of a placeholder for an image. Deprecated: use Uploads instead
Blurhash string `mediatype:"image" json:"blurhash,omitempty"`
// Upload preview height, in pixels, if any. Deprecated: use Uploads instead
PreviewHeight int `mediatype:"image,video" json:"previewHeight,omitempty"`
// Upload width, in pixels, if any. Deprecated: use Uploads instead
PreviewWidth int `mediatype:"image,video" json:"previewWidth,omitempty"`
// Upload preview absolute url, if any. Deprecated: use Uploads instead
PreviewUrl string `mediatype:"image,video" json:"previewURL,omitempty"`
// Upload high resolution preview absolute url, if any. Deprecated: use Uploads instead
Preview2xUrl string `mediatype:"image,video" json:"preview2xURL,omitempty"`
// Upload name, if any. Deprecated: use Uploads instead
Name string `mediatype:"image,video,file" json:"name,omitempty"`
// Upload is animated image, if any. Deprecated: use Uploads instead
Animated bool `mediatype:"image" json:"animated,omitempty"`
// Change title (for "change" mediatype)
Title string `mediatype:"change" json:"title,omitempty"`
// Change old value (for "change" mediatype)
Old *string `mediatype:"change" json:"old,omitempty"`
// Change new value (for "change" mediatype)
New *string `mediatype:"change" json:"new,omitempty"`
// Change actor contact id (for "change" mediatype)
Actor JID `mediatype:"change" json:"actor,omitempty"`
// Comment (for "audiomsg" mediatype)
Comment string `mediatype:"audiomsg" json:"comment,omitempty"`
// Given name (for "contact" mediatype)
GivenName string `mediatype:"contact" json:"given_name,omitempty"`
// Family name (for "contact" mediatype)
FamilyName string `mediatype:"contact" json:"family_name,omitempty"`
// Patronymic name (for "contact" mediatype)
Patronymic string `mediatype:"contact" json:"patronymic,omitempty"`
// Contact phones list (for "contact" mediatype)
Phones []string `mediatype:"contact" json:"phones,omitempty"`
// Emails list (for "contact" mediatype)
Emails []string `mediatype:"contact" json:"emails,omitempty"`
// Stickerpack name (for "sticker" subtype)
Stickerpack string `mediasubtype:"sticker" json:"stickerpack,omitempty"`
// Pdf version, if any
PdfVersion *PdfVersion `json:"pdf_version,omitempty"`
}
// Chat message
type Message struct {
// Message content struct
Content MessageContent `json:"content"`
// Simple plaintext message representation
PushText string `json:"push_text,omitempty" tdproto:"readonly"`
// Sender contact id
From JID `json:"from" tdproto:"readonly"`
// Recipient id (group, task or contact)
To JID `json:"to"`
// Message uid
MessageId string `json:"message_id"`
// Message creation datetime (set by server side) or sending datetime in future for draft messages
Created ISODateTimeString `json:"created" tdproto:"readonly"`
// Creation datetime for draft messages
Drafted ISODateTimeString `json:"drafted,omitempty" tdproto:"readonly"`
// Object version
Gentime int64 `json:"gentime" tdproto:"readonly"`
// Chat type
ChatType ChatType `json:"chat_type" tdproto:"readonly"`
// Chat id
Chat JID `json:"chat" tdproto:"readonly"`
// External/internals links
Links MessageLinks `json:"links,omitempty" tdproto:"readonly"`
// Markup entities. Experimental
Markup []MarkupEntity `json:"markup,omitempty" tdproto:"readonly"`
// Importance flag
Important bool `json:"important,omitempty"`
// ISODateTimeString of message modification or deletion
Edited ISODateTimeString `json:"edited,omitempty" tdproto:"readonly"`
// Message was seen by anybody in chat. True or null
Received bool `json:"received,omitempty" tdproto:"readonly"`
// Unused yet
NumReceived int `json:"num_received,omitempty" tdproto:"readonly"`
// Disable link previews. True or null
Nopreview bool `json:"nopreview,omitempty"`
// Has link previews. True or null
HasPreviews bool `json:"has_previews,omitempty" tdproto:"readonly"`
// Previous message id in this chat. Uid or null
Prev string `json:"prev,omitempty" tdproto:"readonly"`
// This message is first in this chat. True or null
IsFirst bool `json:"is_first,omitempty" tdproto:"readonly"`
// This message is last in this chat. True or null
IsLast bool `json:"is_last,omitempty" tdproto:"readonly"`
// Message uploads
Uploads []Upload `json:"uploads,omitempty"`
// Message reactions struct. Can be null
Reactions []MessageReaction `json:"reactions,omitempty" tdproto:"readonly"`
// Message that was replied to, if any
ReplyTo *Message `json:"reply_to,omitempty"`
// Forwarded messages. Can be null. Also contains double of ReplyTo for backward compatibility
LinkedMessages []Message `json:"linked_messages,omitempty"`
// Has mention (@). True or null
Notice bool `json:"notice,omitempty" tdproto:"readonly"`
// Message has no pushes and did not affect any counters
Silently bool `json:"silently,omitempty" tdproto:"readonly"`
// Author can change this message until date. Can be null
EditableUntil ISODateTimeString `json:"editable_until,omitempty" tdproto:"readonly"`
// Index number of this message. Starts from 0. Null for deleted messages. Changes when any previous message wad deleted.
Num *int `json:"num,omitempty" tdproto:"readonly"`
// This message is archive. True or null
IsArchive bool `json:"is_archive,omitempty" tdproto:"readonly"`
// Debug information, if any
Debug string `json:"_debug,omitempty" tdproto:"readonly"`
// ThreadJID
ThreadJID JID `json:"thread_jid,omitempty"`
// Thread Messages Count
ThreadMessagesCount int `json:"thread_messages_count,omitempty"`
}
// Website title and description
type MessageLinkPreview struct {
// Website title or og:title content
Title string `json:"title"`
// Website description
Description string `json:"description,omitempty"`
}
// Checked message links. In short: "Click here: {link.Pattern}" => "Click here: <a href='{link.Url}'>{link.Text}</a>"
type MessageLink struct {
// Text fragment that should be replaced by link
Pattern string `json:"pattern"`
// Internal or external link
Url string `json:"url"`
// Text replacement.
Text string `json:"text"`
// Optional preview info, for websites
Preview *MessageLinkPreview `json:"preview,omitempty"`
// Optional upload info
Uploads []Upload `json:"uploads,omitempty"`
// Website previews disabled
NoPreview bool `json:"nopreview,omitempty"`
// Optional youtube movie id
YoutubeId string `json:"youtube_id,omitempty"`
}
type MessageLinks []MessageLink
// Message emoji reaction
type MessageReaction struct {
// Emoji
Name string `json:"name"`
// Number of reactions
Counter int `json:"counter"`
// Details
Details []MessageReactionDetail `json:"details"`
}
// Message reaction detail
type MessageReactionDetail struct {
// When reaction added, iso datetime
Created ISODateTimeString `json:"created"`
// Reaction author
Sender JID `json:"sender"`
// Reaction emoji
Name string `json:"name"`
}