Skip to content

Commit 1526255

Browse files
Add message documentation
1 parent 05e04b5 commit 1526255

File tree

1 file changed

+154
-43
lines changed

1 file changed

+154
-43
lines changed

types.go

Lines changed: 154 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -134,49 +134,160 @@ func (c Chat) ChatConfig() ChatConfig {
134134
// Message is returned by almost every request, and contains data about
135135
// almost anything.
136136
type Message struct {
137-
MessageID int `json:"message_id"`
138-
From *User `json:"from"` // optional
139-
Date int `json:"date"`
140-
Chat *Chat `json:"chat"`
141-
ForwardFrom *User `json:"forward_from"` // optional
142-
ForwardFromChat *Chat `json:"forward_from_chat"` // optional
143-
ForwardFromMessageID int `json:"forward_from_message_id"` // optional
144-
ForwardDate int `json:"forward_date"` // optional
145-
ReplyToMessage *Message `json:"reply_to_message"` // optional
146-
ViaBot *User `json:"via_bot"` // optional
147-
EditDate int `json:"edit_date"` // optional
148-
MediaGroupID string `json:"media_group_id"` // optional
149-
AuthorSignature string `json:"author_signature"` // optional
150-
Text string `json:"text"` // optional
151-
Entities *[]MessageEntity `json:"entities"` // optional
152-
CaptionEntities *[]MessageEntity `json:"caption_entities"` // optional
153-
Audio *Audio `json:"audio"` // optional
154-
Document *Document `json:"document"` // optional
155-
Animation *ChatAnimation `json:"animation"` // optional
156-
Game *Game `json:"game"` // optional
157-
Photo *[]PhotoSize `json:"photo"` // optional
158-
Sticker *Sticker `json:"sticker"` // optional
159-
Video *Video `json:"video"` // optional
160-
VideoNote *VideoNote `json:"video_note"` // optional
161-
Voice *Voice `json:"voice"` // optional
162-
Caption string `json:"caption"` // optional
163-
Contact *Contact `json:"contact"` // optional
164-
Location *Location `json:"location"` // optional
165-
Venue *Venue `json:"venue"` // optional
166-
NewChatMembers *[]User `json:"new_chat_members"` // optional
167-
LeftChatMember *User `json:"left_chat_member"` // optional
168-
NewChatTitle string `json:"new_chat_title"` // optional
169-
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional
170-
DeleteChatPhoto bool `json:"delete_chat_photo"` // optional
171-
GroupChatCreated bool `json:"group_chat_created"` // optional
172-
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional
173-
ChannelChatCreated bool `json:"channel_chat_created"` // optional
174-
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
175-
MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional
176-
PinnedMessage *Message `json:"pinned_message"` // optional
177-
Invoice *Invoice `json:"invoice"` // optional
178-
SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // optional
179-
PassportData *PassportData `json:"passport_data,omitempty"` // optional
137+
// MessageID is a unique message identifier inside this chat
138+
MessageID int `json:"message_id"`
139+
// From is a sender, empty for messages sent to channels;
140+
// optional
141+
From *User `json:"from"`
142+
// Date of the message was sent in Unix time
143+
Date int `json:"date"`
144+
// Chat is the conversation the message belongs to
145+
Chat *Chat `json:"chat"`
146+
// ForwardFrom for forwarded messages, sender of the original message;
147+
// optional
148+
ForwardFrom *User `json:"forward_from"`
149+
// ForwardFromChat for messages forwarded from channels,
150+
// information about the original channel;
151+
// optional
152+
ForwardFromChat *Chat `json:"forward_from_chat"`
153+
// ForwardFromMessageID for messages forwarded from channels,
154+
// identifier of the original message in the channel;
155+
// optional
156+
ForwardFromMessageID int `json:"forward_from_message_id"`
157+
// ForwardDate for forwarded messages, date the original message was sent in Unix time;
158+
// optional
159+
ForwardDate int `json:"forward_date"`
160+
// ReplyToMessage for replies, the original message.
161+
// Note that the Message object in this field will not contain further ReplyToMessage fields
162+
// even if it itself is a reply;
163+
// optional
164+
ReplyToMessage *Message `json:"reply_to_message"`
165+
// ViaBot through which the message was sent;
166+
// optional
167+
ViaBot *User `json:"via_bot"`
168+
// EditDate of the message was last edited in Unix time;
169+
// optional
170+
EditDate int `json:"edit_date"`
171+
// MediaGroupID is the unique identifier of a media message group this message belongs to;
172+
// optional
173+
MediaGroupID string `json:"media_group_id"`
174+
// AuthorSignature is the signature of the post author for messages in channels;
175+
// optional
176+
AuthorSignature string `json:"author_signature"`
177+
// Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
178+
// optional
179+
Text string `json:"text"`
180+
// Entities is for text messages, special entities like usernames,
181+
// URLs, bot commands, etc. that appear in the text;
182+
// optional
183+
Entities *[]MessageEntity `json:"entities"`
184+
// CaptionEntities;
185+
// optional
186+
CaptionEntities *[]MessageEntity `json:"caption_entities"`
187+
// Audio message is an audio file, information about the file;
188+
// optional
189+
Audio *Audio `json:"audio"`
190+
// Document message is a general file, information about the file;
191+
// optional
192+
Document *Document `json:"document"`
193+
// Animation message is an animation, information about the animation.
194+
// For backward compatibility, when this field is set, the document field will also be set;
195+
// optional
196+
Animation *ChatAnimation `json:"animation"`
197+
// Game message is a game, information about the game;
198+
// optional
199+
Game *Game `json:"game"`
200+
// Photo message is a photo, available sizes of the photo;
201+
// optional
202+
Photo *[]PhotoSize `json:"photo"`
203+
// Sticker message is a sticker, information about the sticker;
204+
// optional
205+
Sticker *Sticker `json:"sticker"`
206+
// Video message is a video, information about the video;
207+
// optional
208+
Video *Video `json:"video"`
209+
// VideoNote message is a video note, information about the video message;
210+
// optional
211+
VideoNote *VideoNote `json:"video_note"`
212+
// Voice message is a voice message, information about the file;
213+
// optional
214+
Voice *Voice `json:"voice"`
215+
// Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
216+
// optional
217+
Caption string `json:"caption"`
218+
// Contact message is a shared contact, information about the contact;
219+
// optional
220+
Contact *Contact `json:"contact"`
221+
// Location message is a shared location, information about the location;
222+
// optional
223+
Location *Location `json:"location"`
224+
// Venue message is a venue, information about the venue.
225+
// For backward compatibility, when this field is set, the location field will also be set;
226+
// optional
227+
Venue *Venue `json:"venue"`
228+
// NewChatMembers that were added to the group or supergroup
229+
// and information about them (the bot itself may be one of these members);
230+
// optional
231+
NewChatMembers *[]User `json:"new_chat_members"`
232+
// LeftChatMember is a member was removed from the group,
233+
// information about them (this member may be the bot itself);
234+
// optional
235+
LeftChatMember *User `json:"left_chat_member"`
236+
// NewChatTitle is a chat title was changed to this value;
237+
// optional
238+
NewChatTitle string `json:"new_chat_title"`
239+
// NewChatPhoto is a chat photo was change to this value;
240+
// optional
241+
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
242+
// DeleteChatPhoto is a service message: the chat photo was deleted;
243+
// optional
244+
DeleteChatPhoto bool `json:"delete_chat_photo"`
245+
// GroupChatCreated is a service message: the group has been created;
246+
// optional
247+
GroupChatCreated bool `json:"group_chat_created"`
248+
// SuperGroupChatCreated is a service message: the supergroup has been created.
249+
// This field can't be received in a message coming through updates,
250+
// because bot can't be a member of a supergroup when it is created.
251+
// It can only be found in ReplyToMessage if someone replies to a very first message
252+
// in a directly created supergroup;
253+
// optional
254+
SuperGroupChatCreated bool `json:"supergroup_chat_created"`
255+
// ChannelChatCreated is a service message: the channel has been created.
256+
// This field can't be received in a message coming through updates,
257+
// because bot can't be a member of a channel when it is created.
258+
// It can only be found in ReplyToMessage
259+
// if someone replies to a very first message in a channel;
260+
// optional
261+
ChannelChatCreated bool `json:"channel_chat_created"`
262+
// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
263+
// This number may be greater than 32 bits and some programming languages
264+
// may have difficulty/silent defects in interpreting it.
265+
// But it is smaller than 52 bits, so a signed 64 bit integer
266+
// or double-precision float type are safe for storing this identifier;
267+
// optional
268+
MigrateToChatID int64 `json:"migrate_to_chat_id"`
269+
// MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
270+
// This number may be greater than 32 bits and some programming languages
271+
// may have difficulty/silent defects in interpreting it.
272+
// But it is smaller than 52 bits, so a signed 64 bit integer
273+
// or double-precision float type are safe for storing this identifier;
274+
// optional
275+
MigrateFromChatID int64 `json:"migrate_from_chat_id"`
276+
// PinnedMessage is a specified message was pinned.
277+
// Note that the Message object in this field will not contain further ReplyToMessage
278+
// fields even if it is itself a reply;
279+
// optional
280+
PinnedMessage *Message `json:"pinned_message"`
281+
// Invoice message is an invoice for a payment;
282+
// optional
283+
Invoice *Invoice `json:"invoice"`
284+
// SuccessfulPayment message is a service message about a successful payment,
285+
// information about the payment;
286+
// optional
287+
SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
288+
// PassportData is a Telegram Passport data;
289+
// optional
290+
PassportData *PassportData `json:"passport_data,omitempty"`
180291
}
181292

182293
// Time converts the message timestamp into a Time.

0 commit comments

Comments
 (0)