@@ -81,12 +81,17 @@ const (
8181 UpdateMessageEdited UpdateType = "message_edited"
8282 UpdateMessageRemoved UpdateType = "message_removed"
8383 UpdateBotStarted UpdateType = "bot_started"
84+ UpdateBotStopped UpdateType = "bot_stopped"
8485 UpdateBotAdded UpdateType = "bot_added"
8586 UpdateBotRemoved UpdateType = "bot_removed"
8687 UpdateUserAdded UpdateType = "user_added"
8788 UpdateUserRemoved UpdateType = "user_removed"
8889 UpdateChatTitleChanged UpdateType = "chat_title_changed"
8990 UpdateMessageChatCreated UpdateType = "message_chat_created"
91+ UpdateDialogMuted UpdateType = "dialog_muted"
92+ UpdateDialogUnmuted UpdateType = "dialog_unmuted"
93+ UpdateDialogCleared UpdateType = "dialog_cleared"
94+ UpdateDialogRemoved UpdateType = "dialog_removed"
9095)
9196
9297// ChatAdminPermission represents a permission granted to a chat admin.
@@ -101,27 +106,38 @@ const (
101106 PermWrite ChatAdminPermission = "write"
102107)
103108
104- // User represents a Max user.
109+ // User represents a Max user or bot .
105110type User struct {
106- UserID int64 `json:"user_id"`
107- FirstName string `json:"first_name"`
108- LastName * string `json:"last_name,omitempty"`
109- Username * string `json:"username,omitempty"`
110- IsBot bool `json:"is_bot"`
111- LastActivityTime int64 `json:"last_activity_time"`
111+ // Unique identifier of the user or bot.
112+ UserID int64 `json:"user_id"`
113+ // Display name of the user or bot.
114+ FirstName string `json:"first_name"`
115+ // Display last name. Not returned for bots.
116+ LastName * string `json:"last_name,omitempty"`
117+ // Bot username or unique public name. May be null for users.
118+ Username * string `json:"username,omitempty"`
119+ // True if this is a bot.
120+ IsBot bool `json:"is_bot"`
121+ // Last activity time in MAX (Unix time in milliseconds).
122+ // May be absent if the user disabled online status in settings.
123+ LastActivityTime int64 `json:"last_activity_time"`
112124}
113125
114126// UserWithPhoto extends User with avatar and description.
115127type UserWithPhoto struct {
116128 User
117- Description * string `json:"description,omitempty"`
118- AvatarURL string `json:"avatar_url,omitempty"`
119- FullAvatarURL string `json:"full_avatar_url,omitempty"`
129+ // User or bot description (up to 16000 characters).
130+ Description * string `json:"description,omitempty"`
131+ // Small avatar URL.
132+ AvatarURL string `json:"avatar_url,omitempty"`
133+ // Full-size avatar URL.
134+ FullAvatarURL string `json:"full_avatar_url,omitempty"`
120135}
121136
122137// BotInfo represents the bot's info returned by GET /me.
123138type BotInfo struct {
124139 UserWithPhoto
140+ // Commands supported by the bot (up to 32).
125141 Commands []BotCommand `json:"commands,omitempty"`
126142}
127143
@@ -148,22 +164,38 @@ type Image struct {
148164
149165// Chat represents a Max chat.
150166type Chat struct {
151- ChatID int64 `json:"chat_id"`
152- Type ChatType `json:"type"`
153- Status ChatStatus `json:"status"`
154- Title * string `json:"title"`
155- Icon * Image `json:"icon"`
156- LastEventTime int64 `json:"last_event_time"`
157- ParticipantsCount int `json:"participants_count"`
158- OwnerID * int64 `json:"owner_id,omitempty"`
159- Participants map [string ]int64 `json:"participants,omitempty"`
160- IsPublic bool `json:"is_public"`
161- Link * string `json:"link,omitempty"`
162- Description * string `json:"description"`
163- DialogWithUser * UserWithPhoto `json:"dialog_with_user,omitempty"`
164- MessagesCount * int `json:"messages_count,omitempty"`
165- ChatMessageID * string `json:"chat_message_id,omitempty"`
166- PinnedMessage * Message `json:"pinned_message,omitempty"`
167+ // Chat identifier.
168+ ChatID int64 `json:"chat_id"`
169+ // Chat type: "chat" (group), "dialog" (direct), or "channel".
170+ Type ChatType `json:"type"`
171+ // Bot's status in the chat: "active", "removed", "left", "closed".
172+ Status ChatStatus `json:"status"`
173+ // Display title. May be null for dialogs.
174+ Title * string `json:"title"`
175+ // Chat icon.
176+ Icon * Image `json:"icon"`
177+ // Last event time in the chat (Unix time).
178+ LastEventTime int64 `json:"last_event_time"`
179+ // Number of participants. Always 2 for dialogs.
180+ ParticipantsCount int `json:"participants_count"`
181+ // Chat owner ID.
182+ OwnerID * int64 `json:"owner_id,omitempty"`
183+ // Participants with last activity time. May be null for chat lists.
184+ Participants map [string ]int64 `json:"participants,omitempty"`
185+ // Whether the chat is publicly accessible (always false for dialogs).
186+ IsPublic bool `json:"is_public"`
187+ // Chat invite link.
188+ Link * string `json:"link,omitempty"`
189+ // Chat description.
190+ Description * string `json:"description"`
191+ // User info for dialog chats (type "dialog" only).
192+ DialogWithUser * UserWithPhoto `json:"dialog_with_user,omitempty"`
193+ // Message count. Only for group chats and channels, not dialogs.
194+ MessagesCount * int `json:"messages_count,omitempty"`
195+ // ID of the message containing the button that initiated this chat.
196+ ChatMessageID * string `json:"chat_message_id,omitempty"`
197+ // Pinned message. Only returned when requesting a specific chat.
198+ PinnedMessage * Message `json:"pinned_message,omitempty"`
167199}
168200
169201// ChatList represents a paginated list of chats.
@@ -183,12 +215,18 @@ type ChatPatch struct {
183215// ChatMember represents a member of a chat.
184216type ChatMember struct {
185217 UserWithPhoto
186- LastAccessTime int64 `json:"last_access_time"`
187- IsOwner bool `json:"is_owner"`
188- IsAdmin bool `json:"is_admin"`
189- JoinTime int64 `json:"join_time"`
190- Permissions []ChatAdminPermission `json:"permissions"`
191- Alias * string `json:"alias"`
218+ // Last activity time in the chat. May be stale for superchats.
219+ LastAccessTime int64 `json:"last_access_time"`
220+ // Whether the user is the chat owner.
221+ IsOwner bool `json:"is_owner"`
222+ // Whether the user is a chat administrator.
223+ IsAdmin bool `json:"is_admin"`
224+ // Time when the user joined the chat (Unix time).
225+ JoinTime int64 `json:"join_time"`
226+ // Admin permissions. Null if the member is not an admin.
227+ Permissions []ChatAdminPermission `json:"permissions"`
228+ // Custom admin title shown in chat.
229+ Alias * string `json:"alias"`
192230}
193231
194232// ChatMembersList represents a paginated list of chat members.
@@ -223,13 +261,20 @@ type MessageStat struct {
223261
224262// Message represents a message in a chat.
225263type Message struct {
226- Sender * User `json:"sender,omitempty"`
227- Recipient Recipient `json:"recipient"`
228- Timestamp int64 `json:"timestamp"`
229- Link * LinkedMessage `json:"link,omitempty"`
230- Body MessageBody `json:"body"`
231- Stat * MessageStat `json:"stat,omitempty"`
232- URL * string `json:"url,omitempty"`
264+ // User who sent the message.
265+ Sender * User `json:"sender,omitempty"`
266+ // Recipient — can be a user or a chat.
267+ Recipient Recipient `json:"recipient"`
268+ // Message creation time (Unix time).
269+ Timestamp int64 `json:"timestamp"`
270+ // Forwarded or replied-to message.
271+ Link * LinkedMessage `json:"link,omitempty"`
272+ // Message content: text and attachments.
273+ Body MessageBody `json:"body"`
274+ // Message statistics.
275+ Stat * MessageStat `json:"stat,omitempty"`
276+ // Public link to a channel post. Absent for dialogs and group chats.
277+ URL * string `json:"url,omitempty"`
233278}
234279
235280// MessageBody represents the body of a message.
@@ -312,11 +357,16 @@ type MessageList struct {
312357// Use [Some] to set optional fields. Unset fields are omitted from JSON,
313358// which tells the server to keep the existing value when editing a message.
314359type NewMessageBody struct {
315- Text OptString `json:"text,omitzero"`
316- Attachments []AttachmentRequest `json:"attachments,omitzero"`
317- Link * NewMessageLink `json:"link,omitempty"`
318- Notify OptBool `json:"notify,omitzero"`
319- Format Optional [TextFormat ] `json:"format,omitzero"`
360+ // Message text (up to 4000 characters).
361+ Text OptString `json:"text,omitzero"`
362+ // Message attachments. If empty, all existing attachments will be removed.
363+ Attachments []AttachmentRequest `json:"attachments,omitzero"`
364+ // Link to another message (for reply or forward).
365+ Link * NewMessageLink `json:"link,omitempty"`
366+ // If false, chat members will not be notified (default true).
367+ Notify OptBool `json:"notify,omitzero"`
368+ // Text formatting mode: "markdown" or "html".
369+ Format Optional [TextFormat ] `json:"format,omitzero"`
320370
321371 // DisableLinkPreview prevents the server from generating link previews.
322372 // Sent as a query parameter, not in the JSON body.
@@ -476,7 +526,7 @@ type InlineKeyboardAttachment struct {
476526
477527// Button represents a button in an inline keyboard.
478528// Use the Type field to determine the button kind: "callback", "link",
479- // "request_contact", "request_geo_location", "chat", "message".
529+ // "request_contact", "request_geo_location", "chat", "message", "open_app" .
480530type Button struct {
481531 Type string `json:"type"`
482532 Text string `json:"text"`
@@ -488,6 +538,7 @@ type Button struct {
488538 ChatDescription OptString `json:"chat_description,omitzero"`
489539 StartPayload OptString `json:"start_payload,omitzero"`
490540 UUID OptInt64 `json:"uuid,omitzero"`
541+ WebApp string `json:"web_app,omitempty"`
491542}
492543
493544// NewCallbackButton creates a callback button that sends payload to the bot.
@@ -527,6 +578,12 @@ func NewMessageButton(text string) Button {
527578 return Button {Type : "message" , Text : text }
528579}
529580
581+ // NewOpenAppButton creates a button that opens a mini app inside the messenger.
582+ // The webApp parameter is the bot username whose mini app to launch.
583+ func NewOpenAppButton (text , webApp string ) Button {
584+ return Button {Type : "open_app" , Text : text , WebApp : webApp }
585+ }
586+
530587// ReplyButton represents a button in a reply keyboard.
531588type ReplyButton struct {
532589 Type string `json:"type,omitempty"`
@@ -749,14 +806,18 @@ type VideoAttachmentDetails struct {
749806
750807// Update is the base for all update events.
751808type Update struct {
809+ // Discriminator that determines the update type.
752810 UpdateType UpdateType `json:"update_type"`
753- Timestamp int64 `json:"timestamp"`
811+ // Unix time when the event occurred.
812+ Timestamp int64 `json:"timestamp"`
754813}
755814
756815// MessageCreatedUpdate is received when a new message is created.
757816type MessageCreatedUpdate struct {
758817 Update
759- Message Message `json:"message"`
818+ // The newly created message.
819+ Message Message `json:"message"`
820+ // User's current locale (IETF BCP 47). Only available in dialogs.
760821 UserLocale * string `json:"user_locale,omitempty"`
761822}
762823
@@ -841,6 +902,41 @@ type MessageChatCreatedUpdate struct {
841902 StartPayload * string `json:"start_payload,omitempty"`
842903}
843904
905+ // BotStoppedUpdate is received when a user stops the bot.
906+ type BotStoppedUpdate struct {
907+ Update
908+ ChatID int64 `json:"chat_id"`
909+ User User `json:"user"`
910+ }
911+
912+ // DialogMutedUpdate is received when a user mutes the dialog with the bot.
913+ type DialogMutedUpdate struct {
914+ Update
915+ ChatID int64 `json:"chat_id"`
916+ User User `json:"user"`
917+ }
918+
919+ // DialogUnmutedUpdate is received when a user unmutes the dialog with the bot.
920+ type DialogUnmutedUpdate struct {
921+ Update
922+ ChatID int64 `json:"chat_id"`
923+ User User `json:"user"`
924+ }
925+
926+ // DialogClearedUpdate is received when a user clears the dialog history.
927+ type DialogClearedUpdate struct {
928+ Update
929+ ChatID int64 `json:"chat_id"`
930+ User User `json:"user"`
931+ }
932+
933+ // DialogRemovedUpdate is received when a user removes the dialog with the bot.
934+ type DialogRemovedUpdate struct {
935+ Update
936+ ChatID int64 `json:"chat_id"`
937+ User User `json:"user"`
938+ }
939+
844940// UpdateList is the response from GET /updates.
845941type UpdateList struct {
846942 Updates []json.RawMessage `json:"updates"`
0 commit comments