Skip to content

Commit 67d51b9

Browse files
authored
Merge pull request #383 from ilyakaznacheev/api-type-docks-1
Add API type docks pack one
2 parents b6df6c2 + e539815 commit 67d51b9

File tree

1 file changed

+145
-33
lines changed

1 file changed

+145
-33
lines changed

types.go

Lines changed: 145 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,53 @@ type ResponseParameters struct {
2727

2828
// Update is an update response, from GetUpdates.
2929
type Update struct {
30-
UpdateID int `json:"update_id"`
31-
Message *Message `json:"message"`
32-
EditedMessage *Message `json:"edited_message"`
33-
ChannelPost *Message `json:"channel_post"`
34-
EditedChannelPost *Message `json:"edited_channel_post"`
35-
InlineQuery *InlineQuery `json:"inline_query"`
30+
// UpdateID is the update's unique identifier.
31+
// Update identifiers start from a certain positive number and increase sequentially.
32+
// This ID becomes especially handy if you're using Webhooks,
33+
// since it allows you to ignore repeated updates or to restore
34+
// the correct update sequence, should they get out of order.
35+
// If there are no new updates for at least a week, then identifier
36+
// of the next update will be chosen randomly instead of sequentially.
37+
UpdateID int `json:"update_id"`
38+
// Message new incoming message of any kind — text, photo, sticker, etc.
39+
//
40+
// optional
41+
Message *Message `json:"message"`
42+
// EditedMessage
43+
//
44+
// optional
45+
EditedMessage *Message `json:"edited_message"`
46+
// ChannelPost new version of a message that is known to the bot and was edited
47+
//
48+
// optional
49+
ChannelPost *Message `json:"channel_post"`
50+
// EditedChannelPost new incoming channel post of any kind — text, photo, sticker, etc.
51+
//
52+
// optional
53+
EditedChannelPost *Message `json:"edited_channel_post"`
54+
// InlineQuery new incoming inline query
55+
//
56+
// optional
57+
InlineQuery *InlineQuery `json:"inline_query"`
58+
// ChosenInlineResult is the result of an inline query
59+
// that was chosen by a user and sent to their chat partner.
60+
// Please see our documentation on the feedback collecting
61+
// for details on how to enable these updates for your bot.
62+
//
63+
// optional
3664
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
37-
CallbackQuery *CallbackQuery `json:"callback_query"`
38-
ShippingQuery *ShippingQuery `json:"shipping_query"`
39-
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
65+
// CallbackQuery new incoming callback query
66+
//
67+
// optional
68+
CallbackQuery *CallbackQuery `json:"callback_query"`
69+
// ShippingQuery new incoming shipping query. Only for invoices with flexible price
70+
//
71+
// optional
72+
ShippingQuery *ShippingQuery `json:"shipping_query"`
73+
// PreCheckoutQuery new incoming pre-checkout query. Contains full information about checkout
74+
//
75+
// optional
76+
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
4077
}
4178

4279
// UpdatesChannel is the channel for getting updates.
@@ -49,14 +86,29 @@ func (ch UpdatesChannel) Clear() {
4986
}
5087
}
5188

52-
// User is a user on Telegram.
89+
// User represents a Telegram user or bot.
5390
type User struct {
54-
ID int `json:"id"`
55-
FirstName string `json:"first_name"`
56-
LastName string `json:"last_name"` // optional
57-
UserName string `json:"username"` // optional
58-
LanguageCode string `json:"language_code"` // optional
59-
IsBot bool `json:"is_bot"` // optional
91+
// ID is a unique identifier for this user or bot
92+
ID int `json:"id"`
93+
// FirstName user's or bot's first name
94+
FirstName string `json:"first_name"`
95+
// LastName user's or bot's last name
96+
//
97+
// optional
98+
LastName string `json:"last_name"`
99+
// UserName user's or bot's username
100+
//
101+
// optional
102+
UserName string `json:"username"`
103+
// LanguageCode IETF language tag of the user's language
104+
// more info: https://en.wikipedia.org/wiki/IETF_language_tag
105+
//
106+
// optional
107+
LanguageCode string `json:"language_code"`
108+
// IsBot true, if this user is a bot
109+
//
110+
// optional
111+
IsBot bool `json:"is_bot"`
60112
}
61113

62114
// String displays a simple text version of a user.
@@ -87,23 +139,58 @@ type GroupChat struct {
87139

88140
// ChatPhoto represents a chat photo.
89141
type ChatPhoto struct {
142+
// SmallFileID is a file identifier of small (160x160) chat photo.
143+
// This file_id can be used only for photo download and
144+
// only for as long as the photo is not changed.
90145
SmallFileID string `json:"small_file_id"`
91-
BigFileID string `json:"big_file_id"`
146+
// BigFileID is a file identifier of big (640x640) chat photo.
147+
// This file_id can be used only for photo download and
148+
// only for as long as the photo is not changed.
149+
BigFileID string `json:"big_file_id"`
92150
}
93151

94152
// Chat contains information about the place a message was sent.
95153
type Chat struct {
96-
ID int64 `json:"id"`
97-
Type string `json:"type"`
98-
Title string `json:"title"` // optional
99-
UserName string `json:"username"` // optional
100-
FirstName string `json:"first_name"` // optional
101-
LastName string `json:"last_name"` // optional
102-
AllMembersAreAdmins bool `json:"all_members_are_administrators"` // optional
103-
Photo *ChatPhoto `json:"photo"`
104-
Description string `json:"description,omitempty"` // optional
105-
InviteLink string `json:"invite_link,omitempty"` // optional
106-
PinnedMessage *Message `json:"pinned_message"` // optional
154+
// ID is a unique identifier for this chat
155+
ID int64 `json:"id"`
156+
// Type of chat, can be either “private”, “group”, “supergroup” or “channel”
157+
Type string `json:"type"`
158+
// Title for supergroups, channels and group chats
159+
//
160+
// optional
161+
Title string `json:"title"`
162+
// UserName for private chats, supergroups and channels if available
163+
//
164+
// optional
165+
UserName string `json:"username"`
166+
// FirstName of the other party in a private chat
167+
//
168+
// optional
169+
FirstName string `json:"first_name"`
170+
// LastName of the other party in a private chat
171+
//
172+
// optional
173+
LastName string `json:"last_name"`
174+
// AllMembersAreAdmins
175+
//
176+
// optional
177+
AllMembersAreAdmins bool `json:"all_members_are_administrators"`
178+
// Photo is a chat photo
179+
Photo *ChatPhoto `json:"photo"`
180+
// Description for groups, supergroups and channel chats
181+
//
182+
// optional
183+
Description string `json:"description,omitempty"`
184+
// InviteLink is a chat invite link, for groups, supergroups and channel chats.
185+
// Each administrator in a chat generates their own invite links,
186+
// so the bot must first generate the link using exportChatInviteLink
187+
//
188+
// optional
189+
InviteLink string `json:"invite_link,omitempty"`
190+
// PinnedMessage Pinned message, for groups, supergroups and channels
191+
//
192+
// optional
193+
PinnedMessage *Message `json:"pinned_message"`
107194
}
108195

109196
// IsPrivate returns if the Chat is a private conversation.
@@ -360,11 +447,36 @@ func (m *Message) CommandArguments() string {
360447

361448
// MessageEntity contains information about data in a Message.
362449
type MessageEntity struct {
363-
Type string `json:"type"`
364-
Offset int `json:"offset"`
365-
Length int `json:"length"`
366-
URL string `json:"url"` // optional
367-
User *User `json:"user"` // optional
450+
// Type of the entity.
451+
// Can be:
452+
// “mention” (@username),
453+
// “hashtag” (#hashtag),
454+
// “cashtag” ($USD),
455+
// “bot_command” (/start@jobs_bot),
456+
// “url” (https://telegram.org),
457+
// “email” ([email protected]),
458+
// “phone_number” (+1-212-555-0123),
459+
// “bold” (bold text),
460+
// “italic” (italic text),
461+
// “underline” (underlined text),
462+
// “strikethrough” (strikethrough text),
463+
// “code” (monowidth string),
464+
// “pre” (monowidth block),
465+
// “text_link” (for clickable text URLs),
466+
// “text_mention” (for users without usernames)
467+
Type string `json:"type"`
468+
// Offset in UTF-16 code units to the start of the entity
469+
Offset int `json:"offset"`
470+
// Length
471+
Length int `json:"length"`
472+
// URL for “text_link” only, url that will be opened after user taps on the text
473+
//
474+
// optional
475+
URL string `json:"url"`
476+
// User for “text_mention” only, the mentioned user
477+
//
478+
// optional
479+
User *User `json:"user"`
368480
}
369481

370482
// ParseURL attempts to parse a URL contained within a MessageEntity.

0 commit comments

Comments
 (0)