github.com/tada-team/tdproto@v1.51.57/message.go (about) 1 package tdproto 2 3 type Mediatype string 4 5 const ( 6 MediatypePlain Mediatype = "plain" 7 MediatypeChange Mediatype = "change" 8 MediatypeDeleted Mediatype = "deleted" 9 MediatypeFile Mediatype = "file" 10 MediatypeImage Mediatype = "image" 11 MediatypeVideo Mediatype = "video" 12 MediatypeAudiomsg Mediatype = "audiomsg" 13 MediatypeContact Mediatype = "contact" 14 MediatypePdf Mediatype = "pdf" 15 ) 16 17 type Mediasubtype string 18 19 const ( 20 MediaSubtypeSticker Mediasubtype = "sticker" 21 MediaSubtypeNewtask Mediasubtype = "newtask" 22 MediaSubtypeNamed Mediasubtype = "named" 23 ) 24 25 // Chat message content 26 type MessageContent struct { 27 // Text representation of message 28 Text string `json:"text"` 29 30 // Message type 31 Type Mediatype `json:"type"` 32 33 // Message subtype, if any 34 Subtype Mediasubtype `json:"subtype,omitempty"` 35 36 // Upload id, if any. Deprecated: use Uploads instead 37 Upload string `mediatype:"audiomsg,image,video,file" json:"upload,omitempty"` 38 39 // Upload url, if any. Deprecated: use Uploads instead 40 MediaUrl string `mediatype:"audiomsg,image,video,file" json:"mediaURL,omitempty"` 41 42 // Upload size, if any. Deprecated: use Uploads instead 43 Size int `mediatype:"audiomsg,image,video,file" json:"size,omitempty"` 44 45 // Upload duration, if any. Deprecated: use Uploads instead 46 Duration *uint `mediatype:"audiomsg,video" json:"duration,omitempty"` 47 48 // Upload still processing, if any. Deprecated: use Uploads instead 49 Processing bool `mediatype:"video" json:"processing,omitempty"` 50 51 // Compact representation of a placeholder for an image. Deprecated: use Uploads instead 52 Blurhash string `mediatype:"image" json:"blurhash,omitempty"` 53 54 // Upload preview height, in pixels, if any. Deprecated: use Uploads instead 55 PreviewHeight int `mediatype:"image,video" json:"previewHeight,omitempty"` 56 57 // Upload width, in pixels, if any. Deprecated: use Uploads instead 58 PreviewWidth int `mediatype:"image,video" json:"previewWidth,omitempty"` 59 60 // Upload preview absolute url, if any. Deprecated: use Uploads instead 61 PreviewUrl string `mediatype:"image,video" json:"previewURL,omitempty"` 62 63 // Upload high resolution preview absolute url, if any. Deprecated: use Uploads instead 64 Preview2xUrl string `mediatype:"image,video" json:"preview2xURL,omitempty"` 65 66 // Upload name, if any. Deprecated: use Uploads instead 67 Name string `mediatype:"image,video,file" json:"name,omitempty"` 68 69 // Upload is animated image, if any. Deprecated: use Uploads instead 70 Animated bool `mediatype:"image" json:"animated,omitempty"` 71 72 // Change title (for "change" mediatype) 73 Title string `mediatype:"change" json:"title,omitempty"` 74 75 // Change old value (for "change" mediatype) 76 Old *string `mediatype:"change" json:"old,omitempty"` 77 78 // Change new value (for "change" mediatype) 79 New *string `mediatype:"change" json:"new,omitempty"` 80 81 // Change actor contact id (for "change" mediatype) 82 Actor JID `mediatype:"change" json:"actor,omitempty"` 83 84 // Comment (for "audiomsg" mediatype) 85 Comment string `mediatype:"audiomsg" json:"comment,omitempty"` 86 87 // Given name (for "contact" mediatype) 88 GivenName string `mediatype:"contact" json:"given_name,omitempty"` 89 90 // Family name (for "contact" mediatype) 91 FamilyName string `mediatype:"contact" json:"family_name,omitempty"` 92 93 // Patronymic name (for "contact" mediatype) 94 Patronymic string `mediatype:"contact" json:"patronymic,omitempty"` 95 96 // Contact phones list (for "contact" mediatype) 97 Phones []string `mediatype:"contact" json:"phones,omitempty"` 98 99 // Emails list (for "contact" mediatype) 100 Emails []string `mediatype:"contact" json:"emails,omitempty"` 101 102 // Stickerpack name (for "sticker" subtype) 103 Stickerpack string `mediasubtype:"sticker" json:"stickerpack,omitempty"` 104 105 // Pdf version, if any 106 PdfVersion *PdfVersion `json:"pdf_version,omitempty"` 107 } 108 109 // Chat message 110 type Message struct { 111 // Message content struct 112 Content MessageContent `json:"content"` 113 114 // Simple plaintext message representation 115 PushText string `json:"push_text,omitempty" tdproto:"readonly"` 116 117 // Sender contact id 118 From JID `json:"from" tdproto:"readonly"` 119 120 // Recipient id (group, task or contact) 121 To JID `json:"to"` 122 123 // Message uid 124 MessageId string `json:"message_id"` 125 126 // Message creation datetime (set by server side) or sending datetime in future for draft messages 127 Created ISODateTimeString `json:"created" tdproto:"readonly"` 128 129 // Creation datetime for draft messages 130 Drafted ISODateTimeString `json:"drafted,omitempty" tdproto:"readonly"` 131 132 // Object version 133 Gentime int64 `json:"gentime" tdproto:"readonly"` 134 135 // Chat type 136 ChatType ChatType `json:"chat_type" tdproto:"readonly"` 137 138 // Chat id 139 Chat JID `json:"chat" tdproto:"readonly"` 140 141 // External/internals links 142 Links MessageLinks `json:"links,omitempty" tdproto:"readonly"` 143 144 // Markup entities. Experimental 145 Markup []MarkupEntity `json:"markup,omitempty" tdproto:"readonly"` 146 147 // Importance flag 148 Important bool `json:"important,omitempty"` 149 150 // ISODateTimeString of message modification or deletion 151 Edited ISODateTimeString `json:"edited,omitempty" tdproto:"readonly"` 152 153 // Message was seen by anybody in chat. True or null 154 Received bool `json:"received,omitempty" tdproto:"readonly"` 155 156 // Unused yet 157 NumReceived int `json:"num_received,omitempty" tdproto:"readonly"` 158 159 // Disable link previews. True or null 160 Nopreview bool `json:"nopreview,omitempty"` 161 162 // Has link previews. True or null 163 HasPreviews bool `json:"has_previews,omitempty" tdproto:"readonly"` 164 165 // Previous message id in this chat. Uid or null 166 Prev string `json:"prev,omitempty" tdproto:"readonly"` 167 168 // This message is first in this chat. True or null 169 IsFirst bool `json:"is_first,omitempty" tdproto:"readonly"` 170 171 // This message is last in this chat. True or null 172 IsLast bool `json:"is_last,omitempty" tdproto:"readonly"` 173 174 // Message uploads 175 Uploads []Upload `json:"uploads,omitempty"` 176 177 // Message reactions struct. Can be null 178 Reactions []MessageReaction `json:"reactions,omitempty" tdproto:"readonly"` 179 180 // Message that was replied to, if any 181 ReplyTo *Message `json:"reply_to,omitempty"` 182 183 // Forwarded messages. Can be null. Also contains double of ReplyTo for backward compatibility 184 LinkedMessages []Message `json:"linked_messages,omitempty"` 185 186 // Has mention (@). True or null 187 Notice bool `json:"notice,omitempty" tdproto:"readonly"` 188 189 // Message has no pushes and did not affect any counters 190 Silently bool `json:"silently,omitempty" tdproto:"readonly"` 191 192 // Author can change this message until date. Can be null 193 EditableUntil ISODateTimeString `json:"editable_until,omitempty" tdproto:"readonly"` 194 195 // Index number of this message. Starts from 0. Null for deleted messages. Changes when any previous message wad deleted. 196 Num *int `json:"num,omitempty" tdproto:"readonly"` 197 198 // This message is archive. True or null 199 IsArchive bool `json:"is_archive,omitempty" tdproto:"readonly"` 200 201 // Debug information, if any 202 Debug string `json:"_debug,omitempty" tdproto:"readonly"` 203 204 // ThreadJID 205 ThreadJID JID `json:"thread_jid,omitempty"` 206 207 // Thread Messages Count 208 ThreadMessagesCount int `json:"thread_messages_count,omitempty"` 209 } 210 211 // Website title and description 212 type MessageLinkPreview struct { 213 // Website title or og:title content 214 Title string `json:"title"` 215 216 // Website description 217 Description string `json:"description,omitempty"` 218 } 219 220 // Checked message links. In short: "Click here: {link.Pattern}" => "Click here: <a href='{link.Url}'>{link.Text}</a>" 221 type MessageLink struct { 222 // Text fragment that should be replaced by link 223 Pattern string `json:"pattern"` 224 225 // Internal or external link 226 Url string `json:"url"` 227 228 // Text replacement. 229 Text string `json:"text"` 230 231 // Optional preview info, for websites 232 Preview *MessageLinkPreview `json:"preview,omitempty"` 233 234 // Optional upload info 235 Uploads []Upload `json:"uploads,omitempty"` 236 237 // Website previews disabled 238 NoPreview bool `json:"nopreview,omitempty"` 239 240 // Optional youtube movie id 241 YoutubeId string `json:"youtube_id,omitempty"` 242 } 243 244 type MessageLinks []MessageLink 245 246 // Message emoji reaction 247 type MessageReaction struct { 248 // Emoji 249 Name string `json:"name"` 250 251 // Number of reactions 252 Counter int `json:"counter"` 253 254 // Details 255 Details []MessageReactionDetail `json:"details"` 256 } 257 258 // Message reaction detail 259 type MessageReactionDetail struct { 260 // When reaction added, iso datetime 261 Created ISODateTimeString `json:"created"` 262 263 // Reaction author 264 Sender JID `json:"sender"` 265 266 // Reaction emoji 267 Name string `json:"name"` 268 }