aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/telegram/bot/audio.go10
-rw-r--r--api/telegram/bot/bot.go2
-rw-r--r--api/telegram/bot/chat.go39
-rw-r--r--api/telegram/bot/command.go10
-rw-r--r--api/telegram/bot/command_test.go2
-rw-r--r--api/telegram/bot/contact.go6
-rw-r--r--api/telegram/bot/document.go6
-rw-r--r--api/telegram/bot/encrypted_passport_element.go64
-rw-r--r--api/telegram/bot/game.go16
-rw-r--r--api/telegram/bot/inline_keyboard_button.go22
-rw-r--r--api/telegram/bot/inline_query.go11
-rw-r--r--api/telegram/bot/message.go144
-rw-r--r--api/telegram/bot/message_entity.go18
-rw-r--r--api/telegram/bot/message_forward.go16
-rw-r--r--api/telegram/bot/message_request.go16
-rw-r--r--api/telegram/bot/message_test.go2
-rw-r--r--api/telegram/bot/options.go10
-rw-r--r--api/telegram/bot/order_info.go6
-rw-r--r--api/telegram/bot/passport_data.go6
-rw-r--r--api/telegram/bot/pre_checkout_query.go24
-rw-r--r--api/telegram/bot/response.go6
-rw-r--r--api/telegram/bot/shipping_query.go12
-rw-r--r--api/telegram/bot/sticker.go20
-rw-r--r--api/telegram/bot/successful_payment.go20
-rw-r--r--api/telegram/bot/update.go20
-rw-r--r--api/telegram/bot/user.go6
-rw-r--r--api/telegram/bot/venue.go6
-rw-r--r--api/telegram/bot/webhook.go32
-rw-r--r--api/telegram/bot/webhook_info.go18
29 files changed, 274 insertions, 296 deletions
diff --git a/api/telegram/bot/audio.go b/api/telegram/bot/audio.go
index 9824fc13..f5117cb9 100644
--- a/api/telegram/bot/audio.go
+++ b/api/telegram/bot/audio.go
@@ -7,15 +7,15 @@ package bot
// Audio represents an audio file to be treated as music by the Telegram
// clients.
type Audio struct {
- Document
-
- // Duration of the audio in seconds as defined by sender.
- Duration int `json:"duration"`
-
// Optional. Performer of the audio as defined by sender or by audio
// tags.
Performer string `json:"performer"`
// Optional. Title of the audio as defined by sender or by audio tags.
Title string `json:"title"`
+
+ Document
+
+ // Duration of the audio in seconds as defined by sender.
+ Duration int `json:"duration"`
}
diff --git a/api/telegram/bot/bot.go b/api/telegram/bot/bot.go
index ff2decb0..6461ae23 100644
--- a/api/telegram/bot/bot.go
+++ b/api/telegram/bot/bot.go
@@ -97,8 +97,8 @@ type Bot struct {
client *http.Client
webhook *http.Server
user *User
- commands commands
err chan error
+ commands commands
}
// New create and initialize new Telegram bot.
diff --git a/api/telegram/bot/chat.go b/api/telegram/bot/chat.go
index 6e1b0301..ef4e290a 100644
--- a/api/telegram/bot/chat.go
+++ b/api/telegram/bot/chat.go
@@ -14,14 +14,16 @@ const (
// Chat represents a chat.
type Chat struct {
+ // Optional. Default chat member permissions, for groups and
+ // supergroups. Returned only in getChat.
+ Permissions *ChatPermissions `json:"permissions"`
- // Unique identifier for this chat.
- //
- // 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.
- ID int64 `json:"id"`
+ // Optional. Chat photo. Returned only in getChat.
+ Photo *ChatPhoto `json:"chat_photo"`
+
+ // Optional. Pinned message, for groups, supergroups and channels.
+ // Returned only in getChat.
+ PinnedMesage *Message `json:"pinned_mesage"`
// Type of chat, can be either “private”, “group”, “supergroup” or
// “channel”.
@@ -40,9 +42,6 @@ type Chat struct {
// Optional. Last name of the other party in a private chat.
LastName string `json:"last_name"`
- // Optional. Chat photo. Returned only in getChat.
- Photo *ChatPhoto `json:"chat_photo"`
-
// Optional. Description, for groups, supergroups and channel chats.
// Returned only in getChat.
Description string `json:"description"`
@@ -54,23 +53,23 @@ type Chat struct {
// Returned only in getChat.
InviteLink string `json:"invite_link"`
- // Optional. Pinned message, for groups, supergroups and channels.
- // Returned only in getChat.
- PinnedMesage *Message `json:"pinned_mesage"`
+ // Optional. For supergroups, name of group sticker set. Returned only
+ // in getChat.
+ StickerSetName string `json:"sticker_set_name"`
- // Optional. Default chat member permissions, for groups and
- // supergroups. Returned only in getChat.
- Permissions *ChatPermissions `json:"permissions"`
+ // Unique identifier for this chat.
+ //
+ // 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.
+ ID int64 `json:"id"`
// Optional. For supergroups, the minimum allowed delay between
// consecutive messages sent by each unpriviledged user. Returned only
// in getChat.
SlowModeDelay int `json:"slow_mode_delay"`
- // Optional. For supergroups, name of group sticker set. Returned only
- // in getChat.
- StickerSetName string `json:"sticker_set_name"`
-
// Optional. True, if the bot can change the group sticker set.
// Returned only in getChat.
CanSetStickerSet bool `json:"can_set_sticker_set"`
diff --git a/api/telegram/bot/command.go b/api/telegram/bot/command.go
index 4d4b9e17..a4669519 100644
--- a/api/telegram/bot/command.go
+++ b/api/telegram/bot/command.go
@@ -10,17 +10,17 @@ import (
// Command represents a bot command.
type Command struct {
+ // Function that will be called when Bot receive the command.
+ // Handler can read command and its arguments through Message.Command
+ // and Message.CommandArgs.
+ Handler UpdateHandler `json:"-"`
+
// Text of the command, 1-32 characters. Can contain only lowercase
// English letters, digits and underscores.
Command string `json:"command"`
// Description of the command, 3-256 characters.
Description string `json:"description"`
-
- // Function that will be called when Bot receive the command.
- // Handler can read command and its arguments through Message.Command
- // and Message.CommandArgs.
- Handler UpdateHandler `json:"-"`
}
// validate will return an error if command is not valid.
diff --git a/api/telegram/bot/command_test.go b/api/telegram/bot/command_test.go
index d0fdab01..b22b3336 100644
--- a/api/telegram/bot/command_test.go
+++ b/api/telegram/bot/command_test.go
@@ -15,9 +15,9 @@ func TestCommand_validate(t *testing.T) {
s33 := string(ascii.Random([]byte(ascii.Letters), 33))
cases := []struct {
- desc string
cmd Command
exp error
+ desc string
}{{
desc: "with empty command",
cmd: Command{},
diff --git a/api/telegram/bot/contact.go b/api/telegram/bot/contact.go
index b31c0141..39edb93e 100644
--- a/api/telegram/bot/contact.go
+++ b/api/telegram/bot/contact.go
@@ -12,9 +12,9 @@ type Contact struct {
// Optional. Contact's last name.
LastName string `json:"last_name"`
- // Optional. Contact's user identifier in Telegram
- UserID int64 `json:"user_id"`
-
// Optional. Additional data about the contact in the form of a vCard
VCard string `json:"vcard"`
+
+ // Optional. Contact's user identifier in Telegram
+ UserID int64 `json:"user_id"`
}
diff --git a/api/telegram/bot/document.go b/api/telegram/bot/document.go
index c18fe388..25aa0bc6 100644
--- a/api/telegram/bot/document.go
+++ b/api/telegram/bot/document.go
@@ -7,6 +7,9 @@ package bot
// Document represents a general file (as opposed to photos, voice messages
// and audio files).
type Document struct {
+ // Optional. Document thumbnail as defined by sender.
+ Thumb *PhotoSize `json:"thumb"`
+
// Identifier for this file, which can be used to download or reuse
// the file.
FileID string `json:"file_id"`
@@ -24,7 +27,4 @@ type Document struct {
// Optional. File size.
FileSize int `json:"file_size"`
-
- // Optional. Document thumbnail as defined by sender.
- Thumb *PhotoSize `json:"thumb"`
}
diff --git a/api/telegram/bot/encrypted_passport_element.go b/api/telegram/bot/encrypted_passport_element.go
index 0fccf158..2747b29e 100644
--- a/api/telegram/bot/encrypted_passport_element.go
+++ b/api/telegram/bot/encrypted_passport_element.go
@@ -7,75 +7,58 @@ package bot
// EncryptedPassportElement contains information about documents or other
// Telegram Passport elements shared with the bot by the user.
type EncryptedPassportElement struct {
- //
+ // Optional. Encrypted file with the front side of the document,
+ // provided by the user.
+ // Available for “passport”, “driver_license”, “identity_card” and
+ // “internal_passport”. The file can be decrypted and verified using
+ // the accompanying EncryptedCredentials.
+ FrontSide *PassportFile `json:"front_size"`
+
+ // Optional. Encrypted file with the reverse side of the document,
+ // provided by the user.
+ // Available for “driver_license” and “identity_card”.
+ // The file can be decrypted and verified using the accompanying
+ // EncryptedCredentials.
+ ReverseSide *PassportFile `json:"reverse_side"`
+
+ // Optional. Encrypted file with the selfie of the user holding a
+ // document, provided by the user; available for “passport”,
+ // “driver_license”, “identity_card” and “internal_passport”.
+ // The file can be decrypted and verified using the accompanying
+ // EncryptedCredentials.
+ Selfie *PassportFile `json:"selfie"`
+
// Element type. One of “personal_details”, “passport”,
// “driver_license”, “identity_card”, “internal_passport”, “address”,
// “utility_bill”, “bank_statement”, “rental_agreement”,
// “passport_registration”, “temporary_registration”, “phone_number”,
// “email”.
- //
Type string `json:"type"`
- //
// Optional. Base64-encoded encrypted Telegram Passport element data
// provided by the user, available for “personal_details”, “passport”,
// “driver_license”, “identity_card”, “internal_passport” and
// “address” types.
// Can be decrypted and verified using the accompanying
// EncryptedCredentials.
- //
Data string `json:"data"`
- //
// Optional. User's verified phone number, available only for
// “phone_number” type.
- //
PhoneNumber string `json:"phone_number"`
- //
// Optional. User's verified email address, available only for “email”
// type.
- //
Email string `json:"email"`
- //
// Optional. Array of encrypted files with documents provided by the
// user, available for “utility_bill”, “bank_statement”,
// “rental_agreement”, “passport_registration” and
// “temporary_registration” types.
// Files can be decrypted and verified using the accompanying
// EncryptedCredentials.
- //
Files []PassportFile `json:"files"`
- //
- // Optional. Encrypted file with the front side of the document,
- // provided by the user.
- // Available for “passport”, “driver_license”, “identity_card” and
- // “internal_passport”. The file can be decrypted and verified using
- // the accompanying EncryptedCredentials.
- //
- FrontSide *PassportFile `json:"front_size"`
-
- //
- // Optional. Encrypted file with the reverse side of the document,
- // provided by the user.
- // Available for “driver_license” and “identity_card”.
- // The file can be decrypted and verified using the accompanying
- // EncryptedCredentials.
- //
- ReverseSide *PassportFile `json:"reverse_side"`
-
- //
- // Optional. Encrypted file with the selfie of the user holding a
- // document, provided by the user; available for “passport”,
- // “driver_license”, “identity_card” and “internal_passport”.
- // The file can be decrypted and verified using the accompanying
- // EncryptedCredentials.
- //
- Selfie *PassportFile `json:"selfie"`
-
- //
// Optional. Array of encrypted files with translated versions of
// documents provided by the user.
// Available if requested for “passport”, “driver_license”,
@@ -85,10 +68,5 @@ type EncryptedPassportElement struct {
//
// Files can be decrypted and verified using the accompanying
// EncryptedCredentials.
- //
Translation []PassportFile `json:"translation"`
-
- // Base64-encoded element hash for using in
- // PassportElementErrorUnspecified
- Hash string `json:"hash"`
}
diff --git a/api/telegram/bot/game.go b/api/telegram/bot/game.go
index cff13cd7..3207e846 100644
--- a/api/telegram/bot/game.go
+++ b/api/telegram/bot/game.go
@@ -8,27 +8,25 @@ package bot
// Use BotFather to create and edit games, their short names will act as
// unique identifiers.
type Game struct {
+ // Optional. Animation that will be displayed in the game message in
+ // chats. Upload via BotFather.
+ Animation *Animation `json:"animation"`
+
Title string `json:"title"` // Title of the game.
Description string `json:"description"` // Description of the game.
- // Photo that will be displayed in the game message in chats.
- Photo []PhotoSize `json:"photo"`
-
- //
// Optional. Brief description of the game or high scores included in
// the game message.
// Can be automatically edited to include current high scores for the
// game when the bot calls setGameScore, or manually edited using
// editMessageText.
// 0-4096 characters.
- //
Text string `json:"text"`
+ // Photo that will be displayed in the game message in chats.
+ Photo []PhotoSize `json:"photo"`
+
// Optional. Special entities that appear in text, such as usernames,
// URLs, bot commands, etc.
TextEntities []MessageEntity `json:"text_entities"`
-
- // Optional. Animation that will be displayed in the game message in
- // chats. Upload via BotFather.
- Animation *Animation `json:"animation"`
}
diff --git a/api/telegram/bot/inline_keyboard_button.go b/api/telegram/bot/inline_keyboard_button.go
index 755f3670..3b6fcfca 100644
--- a/api/telegram/bot/inline_keyboard_button.go
+++ b/api/telegram/bot/inline_keyboard_button.go
@@ -7,16 +7,23 @@ package bot
// InlineKeyboardButton represents one button of an inline keyboard. You must
// use exactly one of the optional fields.
type InlineKeyboardButton struct {
+ // Optional. An HTTP URL used to automatically authorize the user. Can
+ // be used as a replacement for the Telegram Login Widget.
+ LoginURL *LoginURL `json:"login_url"`
+
+ // Optional. Description of the game that will be launched when the
+ // user presses the button.
+ //
+ // NOTE: This type of button must always be the first button in the
+ // first row.
+ CallbackGame *CallbackGame `json:"callback_game"`
+
// Label text on the button.
Text string `json:"text"`
// Optional. HTTP or tg:// url to be opened when button is pressed.
URL string `json:"url"`
- // Optional. An HTTP URL used to automatically authorize the user. Can
- // be used as a replacement for the Telegram Login Widget.
- LoginURL *LoginURL `json:"login_url"`
-
// Optional. Data to be sent in a callback query to the bot when
// button is pressed, 1-64 bytes.
CallbackData string `json:"callback_data"`
@@ -33,13 +40,6 @@ type InlineKeyboardButton struct {
// inserted.
SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat"`
- // Optional. Description of the game that will be launched when the
- // user presses the button.
- //
- // NOTE: This type of button must always be the first button in the
- // first row.
- CallbackGame *CallbackGame `json:"callback_game"`
-
// Optional. Specify True, to send a Pay button.
//
// NOTE: This type of button must always be the first button in the
diff --git a/api/telegram/bot/inline_query.go b/api/telegram/bot/inline_query.go
index 090432bd..5ba9ad24 100644
--- a/api/telegram/bot/inline_query.go
+++ b/api/telegram/bot/inline_query.go
@@ -8,14 +8,15 @@ package bot
// When the user sends an empty query, your bot could return some default or
// trending results.
type InlineQuery struct {
+ From *User `json:"from"` // Sender
+
+ // Optional. Sender location, only for bots that request user
+ // location.
+ Location *Location `json:"location"`
+
ID string `json:"id"` // Unique identifier for this qery
- From *User `json:"from"` // Sender
Query string `json:"query"` // Text of the query (up to 256 characters).
// Offset of the results to be returned, can be controlled by the bot.
Offset string `json:"offset"`
-
- // Optional. Sender location, only for bots that request user
- // location.
- Location *Location `json:"location"`
}
diff --git a/api/telegram/bot/message.go b/api/telegram/bot/message.go
index 4885ea7e..4bb2a2f9 100644
--- a/api/telegram/bot/message.go
+++ b/api/telegram/bot/message.go
@@ -8,38 +8,17 @@ import "strings"
// Message represents a message.
type Message struct {
- MessageForward
-
- ID int `json:"message_id"` // Unique message identifier inside this chat.
- Date int `json:"date"` // Date the message was sent in Unix time.
- Chat *Chat `json:"chat"` // Conversation the message belongs to.
+ // Chat contains conversation the message belongs to.
+ Chat *Chat `json:"chat"`
// Optional. Sender, empty for messages sent to channels.
From *User `json:"from"`
- // Optional. Date the message was last edited in Unix time
- EditDate int `json:"edit_date"`
-
// Optional. For replies, the original message.
// Note that the Message object in this field will not contain further
// reply_to_message fields even if it itself is a reply.
ReplyTo *Message `json:"reply_to_message"`
- // Optional. The unique identifier of a media message group this
- // message belongs to.
- MediaGroupID string `json:"media_group_id"`
-
- // Optional. Signature of the post author for messages in channels.
- AuthorSignature string `json:"author_signature"`
-
- // Optional. For text messages, the actual UTF-8 text of the message,
- // 0-4096 characters.
- Text string `json:"text"`
-
- // Optional. For text messages, special entities like usernames, URLs,
- // bot commands, etc. that appear in the text.
- Entities []MessageEntity `json:"entities"`
-
// Optional. Message is an audio file, information about the file
Audio *Audio `json:"audio"`
@@ -54,9 +33,6 @@ type Message struct {
// Optional. Message is a game, information about the game.
Game *Game `json:"game"`
- // Optional. Message is a photo, available sizes of the photo.
- Photo []PhotoSize `json:"photo"`
-
// Optional. Message is a sticker, information about the sticker.
Sticker *Sticker `json:"sticker"`
@@ -70,14 +46,6 @@ type Message struct {
// message.
VideoNote *VideoNote `json:"video_note"`
- // Optional. Caption for the animation, audio, document, photo, video
- // or voice, 0-1024 characters.
- Caption string `json:"caption"`
-
- // Optional. For messages with a caption, special entities like
- // usernames, URLs, bot commands, etc. that appear in the caption.
- CaptionEntities []MessageEntity `json:"caption_entities"`
-
// Optional. Message is a shared contact, information about the
// contact.
Contact *Contact `json:"contact"`
@@ -95,6 +63,61 @@ type Message struct {
// Optional. Message is a dice with random value from 1 to 6.
Dice *Dice `json:"dice"`
+ // Optional. Specified message was pinned.
+ // Note that the Message object in this field will not contain further
+ // reply_to_message fields even if it is itself a reply.
+ PinnedMessage *Message `json:"pinned_message"`
+
+ // Optional. Message is an invoice for a payment, information about
+ // the invoice.
+ Invoice *Invoice `json:"invoice"`
+
+ // Optional. Message is a service message about a successful payment,
+ // information about the payment.
+ SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
+
+ // Optional. Telegram Passport data.
+ PassportData *PassportData `json:"passport_data"`
+
+ // Optional. Inline keyboard attached to the message.
+ ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
+
+ // Optional. The unique identifier of a media message group this
+ // message belongs to.
+ MediaGroupID string `json:"media_group_id"`
+
+ // Optional. Signature of the post author for messages in channels.
+ AuthorSignature string `json:"author_signature"`
+
+ // Optional. For text messages, the actual UTF-8 text of the message,
+ // 0-4096 characters.
+ Text string `json:"text"`
+
+ // Optional. Caption for the animation, audio, document, photo, video
+ // or voice, 0-1024 characters.
+ Caption string `json:"caption"`
+
+ // Optional. A chat title was changed to this value.
+ NewChatTitle string `json:"new_chat_title"`
+
+ // Optional. The domain name of the website on which the user has
+ // logged in.
+ ConnectedWebsite string `json:"connected_website"`
+
+ Command string // It will contains the Command name.
+ CommandArgs string // It will contains the Command arguments.
+
+ // Optional. For text messages, special entities like usernames, URLs,
+ // bot commands, etc. that appear in the text.
+ Entities []MessageEntity `json:"entities"`
+
+ // Optional. Message is a photo, available sizes of the photo.
+ Photo []PhotoSize `json:"photo"`
+
+ // Optional. For messages with a caption, special entities like
+ // usernames, URLs, bot commands, etc. that appear in the caption.
+ CaptionEntities []MessageEntity `json:"caption_entities"`
+
// Optional. New members that were added to the group or supergroup
// and information about them (the bot itself may be one of these
// members).
@@ -104,12 +127,25 @@ type Message struct {
// them (this member may be the bot itself).
LeftMembers []*User `json:"left_chat_members"`
- // Optional. A chat title was changed to this value.
- NewChatTitle string `json:"new_chat_title"`
-
// Optional. A chat photo was change to this value.
NewChatPhoto []PhotoSize `json:"new_chat_photo"`
+ MessageForward
+
+ // Optional. The group has been migrated to a supergroup with the
+ // specified identifier.
+ MigrateToChatID int64 `json:"migrate_to_chat_id"`
+
+ // Optional. The supergroup has been migrated from a group with the
+ // specified identifier.
+ MigrateFromChatID int64 `json:"migrate_from_chat_id"`
+
+ ID int `json:"message_id"` // Unique message identifier inside this chat.
+ Date int `json:"date"` // Date the message was sent in Unix time.
+
+ // Optional. Date the message was last edited in Unix time
+ EditDate int `json:"edit_date"`
+
// Optional. Service message: the chat photo was deleted.
IsChatPhotoDeleted bool `json:"delete_chat_photo"`
@@ -129,40 +165,6 @@ type Message struct {
// It can only be found in reply_to_message if someone replies to a
// very first message in a channel.
IsChannelChatCreated bool `json:"channel_chat_created"`
-
- // Optional. The group has been migrated to a supergroup with the
- // specified identifier.
- MigrateToChatID int64 `json:"migrate_to_chat_id"`
-
- // Optional. The supergroup has been migrated from a group with the
- // specified identifier.
- MigrateFromChatID int64 `json:"migrate_from_chat_id"`
-
- // Optional. Specified message was pinned.
- // Note that the Message object in this field will not contain further
- // reply_to_message fields even if it is itself a reply.
- PinnedMessage *Message `json:"pinned_message"`
-
- // Optional. Message is an invoice for a payment, information about
- // the invoice.
- Invoice *Invoice `json:"invoice"`
-
- // Optional. Message is a service message about a successful payment,
- // information about the payment.
- SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
-
- // Optional. The domain name of the website on which the user has
- // logged in.
- ConnectedWebsite string `json:"connected_website"`
-
- // Optional. Telegram Passport data.
- PassportData *PassportData `json:"passport_data"`
-
- // Optional. Inline keyboard attached to the message.
- ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
-
- Command string // It will contains the Command name.
- CommandArgs string // It will contains the Command arguments.
}
// parseCommandArgs parse the Text to get the command and its arguments.
diff --git a/api/telegram/bot/message_entity.go b/api/telegram/bot/message_entity.go
index cd9934ac..fe66357f 100644
--- a/api/telegram/bot/message_entity.go
+++ b/api/telegram/bot/message_entity.go
@@ -25,23 +25,23 @@ const (
// MessageEntity represents one special entity in a text message. For example,
// hashtags, usernames, URLs, etc.
type MessageEntity struct {
+ // Optional. For “text_mention” only, the mentioned user.
+ User *User `json:"user"`
+
// Type of the entity.
Type string `json:"type"`
- // Offset in UTF-16 code units to the start of the entity.
- Offset int `json:"offset"`
-
- // Length of the entity in UTF-16 code units.
- Length int `json:"length"`
-
// Optional. For “text_link” only, url that will be opened after user
// taps on the text.
URL string `json:"url"`
- // Optional. For “text_mention” only, the mentioned user.
- User *User `json:"user"`
-
// Optional. For “pre” only, the programming language of the entity
// text.
Language string `json:"language"`
+
+ // Offset in UTF-16 code units to the start of the entity.
+ Offset int `json:"offset"`
+
+ // Length of the entity in UTF-16 code units.
+ Length int `json:"length"`
}
diff --git a/api/telegram/bot/message_forward.go b/api/telegram/bot/message_forward.go
index d6bf22f2..e6f793ce 100644
--- a/api/telegram/bot/message_forward.go
+++ b/api/telegram/bot/message_forward.go
@@ -6,14 +6,6 @@ package bot
// MessageForward define the content for forwarded message.
type MessageForward struct {
- // Optional. For messages forwarded from channels, identifier of the
- // original message in the channel.
- ForwardID int64 `json:"forward_from_message_id"`
-
- // Optional. For forwarded messages, date the original message was
- // sent in Unix time.
- ForwardDate int64 `json:"forward_date"`
-
// Optional. For forwarded messages, sender of the original message.
ForwardFrom *User `json:"forward_from"`
@@ -28,4 +20,12 @@ type MessageForward struct {
// Optional. Sender's name for messages forwarded from users who
// disallow adding a link to their account in forwarded messages.
ForwardSenderName string `json:"forward_sender_name"`
+
+ // Optional. For messages forwarded from channels, identifier of the
+ // original message in the channel.
+ ForwardID int64 `json:"forward_from_message_id"`
+
+ // Optional. For forwarded messages, date the original message was
+ // sent in Unix time.
+ ForwardDate int64 `json:"forward_date"`
}
diff --git a/api/telegram/bot/message_request.go b/api/telegram/bot/message_request.go
index 63be5dfd..c2183101 100644
--- a/api/telegram/bot/message_request.go
+++ b/api/telegram/bot/message_request.go
@@ -10,6 +10,11 @@ type messageRequest struct {
// channel (in the format @channelusername).
ChatID interface{} `json:"chat_id"`
+ // Additional interface options. A JSON-serialized object for an
+ // inline keyboard, custom reply keyboard, instructions to remove
+ // reply keyboard or to force a reply from the user.
+ ReplyMarkup interface{} `json:"reply_markup,omitempty"`
+
// Text of the message to be sent, 1-4096 characters after entities
// parsing.
Text string `json:"text"`
@@ -18,18 +23,13 @@ type messageRequest struct {
// italic, fixed-width text or inline URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
+ // If the message is a reply, ID of the original message.
+ ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
+
// Disables link previews for links in this message.
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
// Sends the message silently. Users will receive a notification with
// no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
-
- // If the message is a reply, ID of the original message.
- ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
-
- // Additional interface options. A JSON-serialized object for an
- // inline keyboard, custom reply keyboard, instructions to remove
- // reply keyboard or to force a reply from the user.
- ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
diff --git a/api/telegram/bot/message_test.go b/api/telegram/bot/message_test.go
index b676a233..17125708 100644
--- a/api/telegram/bot/message_test.go
+++ b/api/telegram/bot/message_test.go
@@ -12,9 +12,9 @@ import (
func TestMessage_parseCommandArgs(t *testing.T) {
cases := []struct {
- msg Message
expCommand string
expArgs string
+ msg Message
}{{
msg: Message{
Text: "Definisi /analisis",
diff --git a/api/telegram/bot/options.go b/api/telegram/bot/options.go
index 36b6f7fb..0fc15960 100644
--- a/api/telegram/bot/options.go
+++ b/api/telegram/bot/options.go
@@ -33,11 +33,6 @@ type UpdateHandler func(update Update)
// Options to create new Bot.
type Options struct {
- // Required. Your Bot authentication token.
- // This option will be overridden by environment variable
- // TELEGRAM_TOKEN.
- Token string
-
// Required. The function that will be called when Bot receiving
// Updates.
HandleUpdate UpdateHandler
@@ -45,6 +40,11 @@ type Options struct {
// Optional. Set this options if the Bot want to receive updates
// using Webhook.
Webhook *Webhook
+
+ // Required. Your Bot authentication token.
+ // This option will be overridden by environment variable
+ // TELEGRAM_TOKEN.
+ Token string
}
// init check for required fields and initialize empty fields with default
diff --git a/api/telegram/bot/order_info.go b/api/telegram/bot/order_info.go
index b25f9868..a442b667 100644
--- a/api/telegram/bot/order_info.go
+++ b/api/telegram/bot/order_info.go
@@ -6,6 +6,9 @@ package bot
// OrderInfo represents information about an order.
type OrderInfo struct {
+ // Optional. User shipping address
+ ShippingAddress *ShippingAddress `json:"shipping_address"`
+
// Optional. User name
Name string `json:"name"`
@@ -14,7 +17,4 @@ type OrderInfo struct {
// Optional. User email
Email string `json:"email"`
-
- // Optional. User shipping address
- ShippingAddress *ShippingAddress `json:"shipping_address"`
}
diff --git a/api/telegram/bot/passport_data.go b/api/telegram/bot/passport_data.go
index 0df6f1cc..e7d9d271 100644
--- a/api/telegram/bot/passport_data.go
+++ b/api/telegram/bot/passport_data.go
@@ -7,10 +7,10 @@ package bot
// PassportData contains information about Telegram Passport data shared with
// the bot by the user.
type PassportData struct {
+ // Encrypted credentials required to decrypt the data.
+ Credentials EncryptedCredentials
+
// Array with information about documents and other Telegram Passport
// elements that was shared with the bot.
data []EncryptedPassportElement //nolint: structcheck,unused
-
- // Encrypted credentials required to decrypt the data.
- Credentials EncryptedCredentials
}
diff --git a/api/telegram/bot/pre_checkout_query.go b/api/telegram/bot/pre_checkout_query.go
index 0a235d03..f2803598 100644
--- a/api/telegram/bot/pre_checkout_query.go
+++ b/api/telegram/bot/pre_checkout_query.go
@@ -6,15 +6,24 @@ package bot
// PreCheckoutQuery contains information about an incoming pre-checkout query.
type PreCheckoutQuery struct {
- // Unique query identifier.
- ID string `json:"id"`
-
// User who sent the query.
From *User `json:"from"`
+ // Optional. Order info provided by the user.
+ OrderInfo *OrderInfo `json:"order_info"`
+
+ // Unique query identifier.
+ ID string `json:"id"`
+
// Three-letter ISO 4217 currency code.
Currency string `json:"currency"`
+ // Bot specified invoice payload.
+ InvoicePayload string `json:"invoice_payload"`
+
+ // Optional. Identifier of the shipping option chosen by the user.
+ ShippingOptionID string `json:"shipping_option_id"`
+
// Total price in the smallest units of the currency (integer, not
// float/double).
// For example, for a price of US$ 1.45 pass amount = 145.
@@ -22,13 +31,4 @@ type PreCheckoutQuery struct {
// of digits past the decimal point for each currency (2 for the
// majority of currencies).
TotalAmount int `json:"total_amount"`
-
- // Bot specified invoice payload.
- InvoicePayload string `json:"invoice_payload"`
-
- // Optional. Identifier of the shipping option chosen by the user.
- ShippingOptionID string `json:"shipping_option_id"`
-
- // Optional. Order info provided by the user.
- OrderInfo *OrderInfo `json:"order_info"`
}
diff --git a/api/telegram/bot/response.go b/api/telegram/bot/response.go
index 57165a62..5b0f7768 100644
--- a/api/telegram/bot/response.go
+++ b/api/telegram/bot/response.go
@@ -18,11 +18,11 @@ const (
// response is the internal, generic response from API.
type response struct {
- Ok bool `json:"ok"`
+ Result interface{} `json:"result"`
+ Parameters *responseParameters `json:"parameters"`
Description string `json:"description"`
ErrorCode int `json:"error_code"`
- Parameters *responseParameters `json:"parameters"`
- Result interface{} `json:"result"`
+ Ok bool `json:"ok"`
}
// unpack the JSON response.
diff --git a/api/telegram/bot/shipping_query.go b/api/telegram/bot/shipping_query.go
index f41d2dd7..117415fe 100644
--- a/api/telegram/bot/shipping_query.go
+++ b/api/telegram/bot/shipping_query.go
@@ -6,15 +6,15 @@ package bot
// ShippingQuery contains information about an incoming shipping query.
type ShippingQuery struct {
- // Unique query identifier.
- ID string `json:"id"`
-
// User who sent the query.
From *User `json:"from"`
- // Bot specified invoice payload.
- InvoicePayload string `json:"invoice_payload"`
-
// User specified shipping address.
ShippingAddress *ShippingAddress `json:"shipping_address"`
+
+ // Unique query identifier.
+ ID string `json:"id"`
+
+ // Bot specified invoice payload.
+ InvoicePayload string `json:"invoice_payload"`
}
diff --git a/api/telegram/bot/sticker.go b/api/telegram/bot/sticker.go
index fdc36d32..2076204c 100644
--- a/api/telegram/bot/sticker.go
+++ b/api/telegram/bot/sticker.go
@@ -6,13 +6,9 @@ package bot
// Sticker represents a sticker.
type Sticker struct {
- Document
-
- // Sticker width.
- Width int `json:"width"`
-
- // Sticker height.
- Height int `json:"height"`
+ // Optional. For mask stickers, the position where the mask should be
+ // placed.
+ MaskPosition *MaskPosition `json:"mask_position"`
// Optional. Emoji associated with the sticker.
Emoji string `json:"emoji"`
@@ -20,9 +16,13 @@ type Sticker struct {
// Optional. Name of the sticker set to which the sticker belongs.
SetName string `json:"set_name"`
- // Optional. For mask stickers, the position where the mask should be
- // placed.
- MaskPosition *MaskPosition `json:"mask_position"`
+ Document
+
+ // Sticker width.
+ Width int `json:"width"`
+
+ // Sticker height.
+ Height int `json:"height"`
// True, if the sticker is animated.
IsAnimated bool `json:"is_animated"`
diff --git a/api/telegram/bot/successful_payment.go b/api/telegram/bot/successful_payment.go
index 2555d9e3..5a200894 100644
--- a/api/telegram/bot/successful_payment.go
+++ b/api/telegram/bot/successful_payment.go
@@ -6,28 +6,28 @@ package bot
// SuccessfulPayment contains basic information about a successful payment.
type SuccessfulPayment struct {
+ // Optional. Order info provided by the user.
+ OrderInfo *OrderInfo `json:"order_info"`
+
// Three-letter ISO 4217 currency code.
Currency string `json:"currency"`
- // Total price in the smallest units of the currency (integer, not
- // float/double). For example, for a price of US$ 1.45 pass amount =
- // 145. See the exp parameter in currencies.json, it shows the number
- // of digits past the decimal point for each currency (2 for the
- // majority of currencies).
- TotalAmount int `json:"total_amount"`
-
// Bot specified invoice payload.
InvoicePayload string `json:"invoice_payload"`
// Optional. Identifier of the shipping option chosen by the user.
ShippingOptionID string `json:"shipping_option_id"`
- // Optional. Order info provided by the user.
- OrderInfo *OrderInfo `json:"order_info"`
-
// Telegram payment identifier.
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
// Provider payment identifier.
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
+
+ // Total price in the smallest units of the currency (integer, not
+ // float/double). For example, for a price of US$ 1.45 pass amount =
+ // 145. See the exp parameter in currencies.json, it shows the number
+ // of digits past the decimal point for each currency (2 for the
+ // majority of currencies).
+ TotalAmount int `json:"total_amount"`
}
diff --git a/api/telegram/bot/update.go b/api/telegram/bot/update.go
index ab8fe4a8..9321c9e3 100644
--- a/api/telegram/bot/update.go
+++ b/api/telegram/bot/update.go
@@ -7,16 +7,6 @@ package bot
// Update an object represents an incoming update.
// At most one of the optional parameters can be present in any given update.
type Update struct {
- // The update‘s unique identifier.
- // Update identifiers start from a certain positive number and
- // increase sequentially.
- // This ID becomes especially handy if you’re using Webhooks, since it
- // allows you to ignore repeated updates or to restore the correct
- // update sequence, should they get out of order.
- // If there are no new updates for at least a week, then identifier of
- // the next update will be chosen randomly instead of sequentially.
- ID int64 `json:"update_id"`
-
// Optional. New incoming message of any kind — text, photo, sticker,
// etc.
Message *Message `json:"Message"`
@@ -60,4 +50,14 @@ type Update struct {
// Optional. A user changed their answer in a non-anonymous poll. Bots
// receive new votes only in polls that were sent by the bot itself.
PollAnswer *PollAnswer `json:"poll_answer"`
+
+ // The update‘s unique identifier.
+ // Update identifiers start from a certain positive number and
+ // increase sequentially.
+ // This ID becomes especially handy if you’re using Webhooks, since it
+ // allows you to ignore repeated updates or to restore the correct
+ // update sequence, should they get out of order.
+ // If there are no new updates for at least a week, then identifier of
+ // the next update will be chosen randomly instead of sequentially.
+ ID int64 `json:"update_id"`
}
diff --git a/api/telegram/bot/user.go b/api/telegram/bot/user.go
index 01753cfc..37a760f4 100644
--- a/api/telegram/bot/user.go
+++ b/api/telegram/bot/user.go
@@ -6,9 +6,6 @@ package bot
// User represents a Telegram user or bot.
type User struct {
- // Unique identifier for this user or bot
- ID int `json:"id"`
-
// User‘s or bot’s first name.
FirstName string `json:"first_name"`
@@ -21,6 +18,9 @@ type User struct {
// Optional. IETF language tag of the user's language.
LanguageCode string `json:"language_code"`
+ // Unique identifier for this user or bot
+ ID int `json:"id"`
+
// True, if this user is a bot
IsBot bool `json:"is_bot"`
diff --git a/api/telegram/bot/venue.go b/api/telegram/bot/venue.go
index 94882687..71e57877 100644
--- a/api/telegram/bot/venue.go
+++ b/api/telegram/bot/venue.go
@@ -6,9 +6,6 @@ package bot
// Venue represents a venue.
type Venue struct {
- // Venue location.
- Location Location `json:"location"`
-
// Name of the venue.
Title string `json:"title"`
@@ -22,4 +19,7 @@ type Venue struct {
// “arts_entertainment/default”, “arts_entertainment/aquarium” or
// “food/icecream”).
FoursquareType string `json:"foursquare_type"`
+
+ // Venue location.
+ Location Location `json:"location"`
}
diff --git a/api/telegram/bot/webhook.go b/api/telegram/bot/webhook.go
index 809f2cfe..66eda754 100644
--- a/api/telegram/bot/webhook.go
+++ b/api/telegram/bot/webhook.go
@@ -8,23 +8,24 @@ import "crypto/tls"
// Webhook contains options to set Webhook to receive updates.
type Webhook struct {
+ // Optional. The certificate for Bot server when listening for
+ // Webhook.
+ ListenCertificate *tls.Certificate
+
// HTTPS url to send updates to.
// This option will be overridden by environment variable
// TELEGRAM_WEBHOOK_URL.
URL string
+ // Optional. The address and port where the Bot will listen for
+ // Webhook in the following format "<address>:<port>".
+ // Default to ":80" if ListenCertificate is nil or ":443" if not nil.
+ ListenAddress string
+
// Optional. Upload your public key certificate so that the root
// certificate in use can be checked.
Certificate []byte
- // Optional.
- // Maximum allowed number of simultaneous HTTPS connections
- // to the webhook for update delivery, 1-100.
- // Defaults to 40.
- // Use lower values to limit the load on your bot‘s server, and higher
- // values to increase your bot’s throughput.
- MaxConnections int
-
// Optional. A JSON-serialized list of the update types you want your
// bot to receive.
// For example, specify ["message", "edited_channel_post",
@@ -34,12 +35,11 @@ type Webhook struct {
// (default). If not specified, the previous setting will be used.
AllowedUpdates []string
- // Optional. The address and port where the Bot will listen for
- // Webhook in the following format "<address>:<port>".
- // Default to ":80" if ListenCertificate is nil or ":443" if not nil.
- ListenAddress string
-
- // Optional. The certificate for Bot server when listening for
- // Webhook.
- ListenCertificate *tls.Certificate
+ // Optional.
+ // Maximum allowed number of simultaneous HTTPS connections
+ // to the webhook for update delivery, 1-100.
+ // Defaults to 40.
+ // Use lower values to limit the load on your bot‘s server, and higher
+ // values to increase your bot’s throughput.
+ MaxConnections int
}
diff --git a/api/telegram/bot/webhook_info.go b/api/telegram/bot/webhook_info.go
index 8f015df9..ecb45d5d 100644
--- a/api/telegram/bot/webhook_info.go
+++ b/api/telegram/bot/webhook_info.go
@@ -9,6 +9,15 @@ type WebhookInfo struct {
// Webhook URL, may be empty if webhook is not set up.
URL string `json:"url"`
+ // Optional. Error message in human-readable format for the most
+ // recent error that happened when trying to deliver an update via
+ // webhook.
+ LastErrorMessage string `json:"last_error_message"`
+
+ // Optional. A list of update types the bot is subscribed to. Defaults
+ // to all update types.
+ AllowedUpdates []string `json:"allowed_updates"`
+
// Number of updates awaiting delivery
PendingUpdateCount int `json:"pending_update_count"`
@@ -16,19 +25,10 @@ type WebhookInfo struct {
// trying to deliver an update via webhook.
LastErrorDate int `json:"last_error_date"`
- // Optional. Error message in human-readable format for the most
- // recent error that happened when trying to deliver an update via
- // webhook.
- LastErrorMessage string `json:"last_error_message"`
-
// Optional. Maximum allowed number of simultaneous HTTPS connections
// to the webhook for update delivery.
MaxConnections int `json:"max_connections"`
- // Optional. A list of update types the bot is subscribed to. Defaults
- // to all update types.
- AllowedUpdates []string `json:"allowed_updates"`
-
// True, if a custom certificate was provided for webhook certificate
// checks.
HasCustomCertificate bool `json:"has_custom_certificate"`