Merge pull request #379 from ilyakaznacheev/add-message-docs

Add message documentation
bot-api-6.1
TJ Horner 2020-10-19 16:56:49 -04:00 committed by GitHub
commit 0a3a1c8716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 154 additions and 43 deletions

197
types.go
View File

@ -134,49 +134,160 @@ func (c Chat) ChatConfig() ChatConfig {
// Message is returned by almost every request, and contains data about // Message is returned by almost every request, and contains data about
// almost anything. // almost anything.
type Message struct { type Message struct {
MessageID int `json:"message_id"` // MessageID is a unique message identifier inside this chat
From *User `json:"from"` // optional MessageID int `json:"message_id"`
Date int `json:"date"` // From is a sender, empty for messages sent to channels;
Chat *Chat `json:"chat"` // optional
ForwardFrom *User `json:"forward_from"` // optional From *User `json:"from"`
ForwardFromChat *Chat `json:"forward_from_chat"` // optional // Date of the message was sent in Unix time
ForwardFromMessageID int `json:"forward_from_message_id"` // optional Date int `json:"date"`
ForwardDate int `json:"forward_date"` // optional // Chat is the conversation the message belongs to
ReplyToMessage *Message `json:"reply_to_message"` // optional Chat *Chat `json:"chat"`
ViaBot *User `json:"via_bot"` // optional // ForwardFrom for forwarded messages, sender of the original message;
EditDate int `json:"edit_date"` // optional // optional
MediaGroupID string `json:"media_group_id"` // optional ForwardFrom *User `json:"forward_from"`
AuthorSignature string `json:"author_signature"` // optional // ForwardFromChat for messages forwarded from channels,
Text string `json:"text"` // optional // information about the original channel;
Entities *[]MessageEntity `json:"entities"` // optional // optional
CaptionEntities *[]MessageEntity `json:"caption_entities"` // optional ForwardFromChat *Chat `json:"forward_from_chat"`
Audio *Audio `json:"audio"` // optional // ForwardFromMessageID for messages forwarded from channels,
Document *Document `json:"document"` // optional // identifier of the original message in the channel;
Animation *ChatAnimation `json:"animation"` // optional // optional
Game *Game `json:"game"` // optional ForwardFromMessageID int `json:"forward_from_message_id"`
Photo *[]PhotoSize `json:"photo"` // optional // ForwardDate for forwarded messages, date the original message was sent in Unix time;
Sticker *Sticker `json:"sticker"` // optional // optional
Video *Video `json:"video"` // optional ForwardDate int `json:"forward_date"`
VideoNote *VideoNote `json:"video_note"` // optional // ReplyToMessage for replies, the original message.
Voice *Voice `json:"voice"` // optional // Note that the Message object in this field will not contain further ReplyToMessage fields
Caption string `json:"caption"` // optional // even if it itself is a reply;
Contact *Contact `json:"contact"` // optional // optional
Location *Location `json:"location"` // optional ReplyToMessage *Message `json:"reply_to_message"`
Venue *Venue `json:"venue"` // optional // ViaBot through which the message was sent;
NewChatMembers *[]User `json:"new_chat_members"` // optional // optional
LeftChatMember *User `json:"left_chat_member"` // optional ViaBot *User `json:"via_bot"`
NewChatTitle string `json:"new_chat_title"` // optional // EditDate of the message was last edited in Unix time;
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional // optional
DeleteChatPhoto bool `json:"delete_chat_photo"` // optional EditDate int `json:"edit_date"`
GroupChatCreated bool `json:"group_chat_created"` // optional // MediaGroupID is the unique identifier of a media message group this message belongs to;
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional // optional
ChannelChatCreated bool `json:"channel_chat_created"` // optional MediaGroupID string `json:"media_group_id"`
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional // AuthorSignature is the signature of the post author for messages in channels;
MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional // optional
PinnedMessage *Message `json:"pinned_message"` // optional AuthorSignature string `json:"author_signature"`
Invoice *Invoice `json:"invoice"` // optional // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // optional // optional
PassportData *PassportData `json:"passport_data,omitempty"` // optional Text string `json:"text"`
// Entities is for text messages, special entities like usernames,
// URLs, bot commands, etc. that appear in the text;
// optional
Entities *[]MessageEntity `json:"entities"`
// CaptionEntities;
// optional
CaptionEntities *[]MessageEntity `json:"caption_entities"`
// Audio message is an audio file, information about the file;
// optional
Audio *Audio `json:"audio"`
// Document message is a general file, information about the file;
// optional
Document *Document `json:"document"`
// Animation message is an animation, information about the animation.
// For backward compatibility, when this field is set, the document field will also be set;
// optional
Animation *ChatAnimation `json:"animation"`
// Game message is a game, information about the game;
// optional
Game *Game `json:"game"`
// Photo message is a photo, available sizes of the photo;
// optional
Photo *[]PhotoSize `json:"photo"`
// Sticker message is a sticker, information about the sticker;
// optional
Sticker *Sticker `json:"sticker"`
// Video message is a video, information about the video;
// optional
Video *Video `json:"video"`
// VideoNote message is a video note, information about the video message;
// optional
VideoNote *VideoNote `json:"video_note"`
// Voice message is a voice message, information about the file;
// optional
Voice *Voice `json:"voice"`
// Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
// optional
Caption string `json:"caption"`
// Contact message is a shared contact, information about the contact;
// optional
Contact *Contact `json:"contact"`
// Location message is a shared location, information about the location;
// optional
Location *Location `json:"location"`
// Venue message is a venue, information about the venue.
// For backward compatibility, when this field is set, the location field will also be set;
// optional
Venue *Venue `json:"venue"`
// NewChatMembers that were added to the group or supergroup
// and information about them (the bot itself may be one of these members);
// optional
NewChatMembers *[]User `json:"new_chat_members"`
// LeftChatMember is a member was removed from the group,
// information about them (this member may be the bot itself);
// optional
LeftChatMember *User `json:"left_chat_member"`
// NewChatTitle is a chat title was changed to this value;
// optional
NewChatTitle string `json:"new_chat_title"`
// NewChatPhoto is a chat photo was change to this value;
// optional
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
// DeleteChatPhoto is a service message: the chat photo was deleted;
// optional
DeleteChatPhoto bool `json:"delete_chat_photo"`
// GroupChatCreated is a service message: the group has been created;
// optional
GroupChatCreated bool `json:"group_chat_created"`
// SuperGroupChatCreated is a service message: the supergroup has been created.
// This field can't be received in a message coming through updates,
// because bot can't be a member of a supergroup when it is created.
// It can only be found in ReplyToMessage if someone replies to a very first message
// in a directly created supergroup;
// optional
SuperGroupChatCreated bool `json:"supergroup_chat_created"`
// ChannelChatCreated is a service message: the channel has been created.
// This field can't be received in a message coming through updates,
// because bot can't be a member of a channel when it is created.
// It can only be found in ReplyToMessage
// if someone replies to a very first message in a channel;
// optional
ChannelChatCreated bool `json:"channel_chat_created"`
// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
// This number may be greater than 32 bits and some programming languages
// may have difficulty/silent defects in interpreting it.
// But it is smaller than 52 bits, so a signed 64 bit integer
// or double-precision float type are safe for storing this identifier;
// optional
MigrateToChatID int64 `json:"migrate_to_chat_id"`
// MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
// This number may be greater than 32 bits and some programming languages
// may have difficulty/silent defects in interpreting it.
// But it is smaller than 52 bits, so a signed 64 bit integer
// or double-precision float type are safe for storing this identifier;
// optional
MigrateFromChatID int64 `json:"migrate_from_chat_id"`
// PinnedMessage is a specified message was pinned.
// Note that the Message object in this field will not contain further ReplyToMessage
// fields even if it is itself a reply;
// optional
PinnedMessage *Message `json:"pinned_message"`
// Invoice message is an invoice for a payment;
// optional
Invoice *Invoice `json:"invoice"`
// SuccessfulPayment message is a service message about a successful payment,
// information about the payment;
// optional
SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
// PassportData is a Telegram Passport data;
// optional
PassportData *PassportData `json:"passport_data,omitempty"`
} }
// Time converts the message timestamp into a Time. // Time converts the message timestamp into a Time.