👽 Updated code to Bot API v4.5
This commit is contained in:
parent
5f0d7efc61
commit
7659fbb9f5
8
const.go
8
const.go
|
@ -47,8 +47,10 @@ const (
|
||||||
EntityMention string = "mention"
|
EntityMention string = "mention"
|
||||||
EntityPhoneNumber string = "phone_number"
|
EntityPhoneNumber string = "phone_number"
|
||||||
EntityPre string = "pre"
|
EntityPre string = "pre"
|
||||||
|
EntityStrikethrough string = "strikethrough"
|
||||||
EntityTextLink string = "text_link"
|
EntityTextLink string = "text_link"
|
||||||
EntityTextMention string = "text_mention"
|
EntityTextMention string = "text_mention"
|
||||||
|
EntityUnderline string = "underline"
|
||||||
EntityURL string = "url"
|
EntityURL string = "url"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -105,6 +107,7 @@ const (
|
||||||
MethodSendVideo string = "sendVideo"
|
MethodSendVideo string = "sendVideo"
|
||||||
MethodSendVideoNote string = "sendVideoNote"
|
MethodSendVideoNote string = "sendVideoNote"
|
||||||
MethodSendVoice string = "sendVoice"
|
MethodSendVoice string = "sendVoice"
|
||||||
|
MethodSetChatAdministratorCustomTitle string = "setChatAdministratorCustomTitle"
|
||||||
MethodSetChatDescription string = "setChatDescription"
|
MethodSetChatDescription string = "setChatDescription"
|
||||||
MethodSetChatPermissions string = "setChatPermissions"
|
MethodSetChatPermissions string = "setChatPermissions"
|
||||||
MethodSetChatPhoto string = "setChatPhoto"
|
MethodSetChatPhoto string = "setChatPhoto"
|
||||||
|
@ -123,8 +126,9 @@ const (
|
||||||
|
|
||||||
// Mode represents available and supported parsing modes of messages
|
// Mode represents available and supported parsing modes of messages
|
||||||
const (
|
const (
|
||||||
StyleHTML string = "html"
|
ParseModeHTML string = "HTML"
|
||||||
StyleMarkdown string = "markdown"
|
ParseModeMarkdown string = "Markdown"
|
||||||
|
ParseModeMarkdownV2 string = "MarkdownV2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mime represents available and supported MIME types of data
|
// Mime represents available and supported MIME types of data
|
||||||
|
|
28
set.go
28
set.go
|
@ -128,6 +128,17 @@ type (
|
||||||
// New default chat permissions
|
// New default chat permissions
|
||||||
Permissions ChatPermissions `json:"permissions"`
|
Permissions ChatPermissions `json:"permissions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetChatAdministratorCustomTitle struct {
|
||||||
|
// Unique identifier for the target chat
|
||||||
|
ChatID int64 `json:"chat_id"`
|
||||||
|
|
||||||
|
// Unique identifier of the target user
|
||||||
|
UserID int `json:"user_id"`
|
||||||
|
|
||||||
|
// New custom title for the administrator; 0-16 characters, emoji are not allowed
|
||||||
|
CustomTitle string `json:"custom_title"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewWebhook creates new SetWebhookParameters only with required parameters.
|
// NewWebhook creates new SetWebhookParameters only with required parameters.
|
||||||
|
@ -368,3 +379,20 @@ func (b *Bot) SetChatPermissions(params SetChatPermissionsParameters) (bool, err
|
||||||
err = parser.Unmarshal(resp.Result, &ok)
|
err = parser.Unmarshal(resp.Result, &ok)
|
||||||
return ok, err
|
return ok, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetChatAdministratorCustomTitle method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
|
||||||
|
func (b *Bot) SetChatAdministratorCustomTitle(params SetChatAdministratorCustomTitle) (bool, error) {
|
||||||
|
dst, err := parser.Marshal(¶ms)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := b.request(dst, MethodSetChatAdministratorCustomTitle)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
err = parser.Unmarshal(resp.Result, &ok)
|
||||||
|
return ok, err
|
||||||
|
}
|
||||||
|
|
143
types.go
143
types.go
|
@ -10,7 +10,7 @@ type (
|
||||||
// especially handy if you’re using Webhooks, since it allows you to
|
// especially handy if you’re using Webhooks, since it allows you to
|
||||||
// ignore repeated updates or to restore the correct update sequence,
|
// ignore repeated updates or to restore the correct update sequence,
|
||||||
// should they get out of order.
|
// should they get out of order.
|
||||||
ID int `json:"update_id"`
|
UpdateID int `json:"update_id"`
|
||||||
|
|
||||||
// New incoming message of any kind — text, photo, sticker, etc.
|
// New incoming message of any kind — text, photo, sticker, etc.
|
||||||
Message *Message `json:"message,omitempty"`
|
Message *Message `json:"message,omitempty"`
|
||||||
|
@ -132,6 +132,9 @@ type (
|
||||||
// Default chat member permissions, for groups and supergroups. Returned only in getChat.
|
// Default chat member permissions, for groups and supergroups. Returned only in getChat.
|
||||||
Permissions *ChatPermissions `json:"permissions,omitempty"`
|
Permissions *ChatPermissions `json:"permissions,omitempty"`
|
||||||
|
|
||||||
|
// For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in getChat.
|
||||||
|
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
|
||||||
|
|
||||||
// For supergroups, name of Group sticker set. Returned only in getChat.
|
// For supergroups, name of Group sticker set. Returned only in getChat.
|
||||||
StickerSetName string `json:"sticker_set_name,omitempty"`
|
StickerSetName string `json:"sticker_set_name,omitempty"`
|
||||||
|
|
||||||
|
@ -336,9 +339,12 @@ type (
|
||||||
|
|
||||||
// PhotoSize represents one size of a photo or a file / sticker thumbnail.
|
// PhotoSize represents one size of a photo or a file / sticker thumbnail.
|
||||||
PhotoSize struct {
|
PhotoSize struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// Photo width
|
// Photo width
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
|
|
||||||
|
@ -352,9 +358,15 @@ type (
|
||||||
// Audio represents an audio file to be treated as music by the Telegram
|
// Audio represents an audio file to be treated as music by the Telegram
|
||||||
// clients.
|
// clients.
|
||||||
Audio struct {
|
Audio struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
|
// Duration of the audio in seconds as defined by sender
|
||||||
|
Duration int `json:"duration"`
|
||||||
|
|
||||||
// Performer of the audio as defined by sender or by audio tags
|
// Performer of the audio as defined by sender or by audio tags
|
||||||
Performer string `json:"performer,omitempty"`
|
Performer string `json:"performer,omitempty"`
|
||||||
|
|
||||||
|
@ -364,9 +376,6 @@ type (
|
||||||
// MIME type of the file as defined by sender
|
// MIME type of the file as defined by sender
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
|
|
||||||
// Duration of the audio in seconds as defined by sender
|
|
||||||
Duration int `json:"duration"`
|
|
||||||
|
|
||||||
// File size
|
// File size
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
|
|
||||||
|
@ -377,29 +386,32 @@ type (
|
||||||
// Document represents a general file (as opposed to photos, voice messages
|
// Document represents a general file (as opposed to photos, voice messages
|
||||||
// and audio files).
|
// and audio files).
|
||||||
Document struct {
|
Document struct {
|
||||||
// Unique file identifier
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
|
// Document thumbnail as defined by sender
|
||||||
|
Thumb *PhotoSize `json:"thumb,omitempty"`
|
||||||
|
|
||||||
// Original filename as defined by sender
|
// Original filename as defined by sender
|
||||||
FileName string `json:"file_name,omitempty"`
|
FileName string `json:"file_name,omitempty"`
|
||||||
|
|
||||||
// MIME type of the file as defined by sender
|
// MIME type of the file as defined by sender
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
|
|
||||||
// Document thumbnail as defined by sender
|
|
||||||
Thumb *PhotoSize `json:"thumb,omitempty"`
|
|
||||||
|
|
||||||
// File size
|
// File size
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video represents a video file.
|
// Video represents a video file.
|
||||||
Video struct {
|
Video struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
// Mime type of a file as defined by sender
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// Video width as defined by sender
|
// Video width as defined by sender
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
|
@ -410,24 +422,30 @@ type (
|
||||||
// Duration of the video in seconds as defined by sender
|
// Duration of the video in seconds as defined by sender
|
||||||
Duration int `json:"duration"`
|
Duration int `json:"duration"`
|
||||||
|
|
||||||
// File size
|
|
||||||
FileSize int `json:"file_size,omitempty"`
|
|
||||||
|
|
||||||
// Video thumbnail
|
// Video thumbnail
|
||||||
Thumb *PhotoSize `json:"thumb,omitempty"`
|
Thumb *PhotoSize `json:"thumb,omitempty"`
|
||||||
|
|
||||||
|
// Mime type of a file as defined by sender
|
||||||
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
|
|
||||||
|
// File size
|
||||||
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Voice represents a voice note.
|
// Voice represents a voice note.
|
||||||
Voice struct {
|
Voice struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
// MIME type of the file as defined by sender
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// Duration of the audio in seconds as defined by sender
|
// Duration of the audio in seconds as defined by sender
|
||||||
Duration int `json:"duration"`
|
Duration int `json:"duration"`
|
||||||
|
|
||||||
|
// MIME type of the file as defined by sender
|
||||||
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
|
|
||||||
// File size
|
// File size
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -435,20 +453,23 @@ type (
|
||||||
// VideoNote represents a video message (available in Telegram apps as of
|
// VideoNote represents a video message (available in Telegram apps as of
|
||||||
// v.4.0).
|
// v.4.0).
|
||||||
VideoNote struct {
|
VideoNote struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// Video width and height (diameter of the video message) as defined by sender
|
// Video width and height (diameter of the video message) as defined by sender
|
||||||
Length int `json:"length"`
|
Length int `json:"length"`
|
||||||
|
|
||||||
// Duration of the video in seconds as defined by sender
|
// Duration of the video in seconds as defined by sender
|
||||||
Duration int `json:"duration"`
|
Duration int `json:"duration"`
|
||||||
|
|
||||||
// File size
|
|
||||||
FileSize int `json:"file_size,omitempty"`
|
|
||||||
|
|
||||||
// Video thumbnail
|
// Video thumbnail
|
||||||
Thumb *PhotoSize `json:"thumb,omitempty"`
|
Thumb *PhotoSize `json:"thumb,omitempty"`
|
||||||
|
|
||||||
|
// File size
|
||||||
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contact represents a phone contact.
|
// Contact represents a phone contact.
|
||||||
|
@ -538,15 +559,18 @@ type (
|
||||||
//
|
//
|
||||||
// Maximum file size to download is 20 MB
|
// Maximum file size to download is 20 MB
|
||||||
File struct {
|
File struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
|
// File size, if known
|
||||||
|
FileSize int `json:"file_size,omitempty"`
|
||||||
|
|
||||||
// File path. Use https://api.telegram.org/file/bot<token>/<file_path> to
|
// File path. Use https://api.telegram.org/file/bot<token>/<file_path> to
|
||||||
// get the file.
|
// get the file.
|
||||||
FilePath string `json:"file_path,omitempty"`
|
FilePath string `json:"file_path,omitempty"`
|
||||||
|
|
||||||
// File size, if known
|
|
||||||
FileSize int `json:"file_size,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplyKeyboardMarkup represents a custom keyboard with reply options (see
|
// ReplyKeyboardMarkup represents a custom keyboard with reply options (see
|
||||||
|
@ -761,15 +785,17 @@ type (
|
||||||
|
|
||||||
// ChatPhoto represents a chat photo.
|
// ChatPhoto represents a chat photo.
|
||||||
ChatPhoto struct {
|
ChatPhoto struct {
|
||||||
// Unique file identifier of small (160x160) chat photo. This file_id can
|
// File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.
|
||||||
// be used only for photo download. This file_id can be used only for photo download and only for as
|
|
||||||
// long as the photo is not changed.
|
|
||||||
SmallFileID string `json:"small_file_id"`
|
SmallFileID string `json:"small_file_id"`
|
||||||
|
|
||||||
// Unique file identifier of big (640x640) chat photo. This file_id can
|
// Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
// be used only for photo download. This file_id can be used only for photo download and only for as
|
SmallFileUniqueID string `json:"small_file_unique_id"`
|
||||||
// long as the photo is not changed.
|
|
||||||
|
// File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.
|
||||||
BigFileID string `json:"big_file_id"`
|
BigFileID string `json:"big_file_id"`
|
||||||
|
|
||||||
|
// Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
BigFileUniqueID string `json:"big_file_unique_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatMember contains information about one member of a chat.
|
// ChatMember contains information about one member of a chat.
|
||||||
|
@ -781,6 +807,9 @@ type (
|
||||||
// or "kicked"
|
// or "kicked"
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Owner and administrators only. Custom title for this user
|
||||||
|
CustomTitle string `json:"custom_title,omitempty"`
|
||||||
|
|
||||||
// Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
|
// Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
|
||||||
UntilDate int64 `json:"until_date,omitempty"`
|
UntilDate int64 `json:"until_date,omitempty"`
|
||||||
|
|
||||||
|
@ -1060,15 +1089,27 @@ type (
|
||||||
// Unique file identifier
|
// Unique file identifier
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
|
// Video width as defined by sender
|
||||||
|
Width int `json:"width"`
|
||||||
|
|
||||||
|
// Video height as defined by sender
|
||||||
|
Height int `json:"height"`
|
||||||
|
|
||||||
|
// Duration of the video in seconds as defined by sender
|
||||||
|
Duration int `json:"duration"`
|
||||||
|
|
||||||
|
// Animation thumbnail as defined by sender
|
||||||
|
Thumb *PhotoSize `json:"thumb,omitempty"`
|
||||||
|
|
||||||
// Original animation filename as defined by sender
|
// Original animation filename as defined by sender
|
||||||
FileName string `json:"file_name,omitempty"`
|
FileName string `json:"file_name,omitempty"`
|
||||||
|
|
||||||
// MIME type of the file as defined by sender
|
// MIME type of the file as defined by sender
|
||||||
MimeType string `json:"mime_type,omitempty"`
|
MimeType string `json:"mime_type,omitempty"`
|
||||||
|
|
||||||
// Animation thumbnail as defined by sender
|
|
||||||
Thumb *PhotoSize `json:"thumb,omitempty"`
|
|
||||||
|
|
||||||
// File size
|
// File size
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -2191,14 +2232,17 @@ type (
|
||||||
// Telegram Passport files are in JPEG format when decrypted and don't exceed
|
// Telegram Passport files are in JPEG format when decrypted and don't exceed
|
||||||
// 10MB.
|
// 10MB.
|
||||||
PassportFile struct {
|
PassportFile struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// File size
|
// File size
|
||||||
FileSize int `json:"file_size"`
|
FileSize int `json:"file_size"`
|
||||||
|
|
||||||
// Unix time when the file was uploaded
|
// Unix time when the file was uploaded
|
||||||
FileDate int64 `json:"file_date"`
|
FileDate int `json:"file_date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Credentials is a JSON-serialized object.
|
// Credentials is a JSON-serialized object.
|
||||||
|
@ -2698,14 +2742,11 @@ type (
|
||||||
|
|
||||||
// Sticker represents a sticker.
|
// Sticker represents a sticker.
|
||||||
Sticker struct {
|
Sticker struct {
|
||||||
// Unique identifier for this file
|
// Identifier for this file, which can be used to download or reuse the file
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
|
|
||||||
// Emoji associated with the sticker
|
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
|
||||||
Emoji string `json:"emoji,omitempty"`
|
FileUniqueID string `json:"file_unique_id"`
|
||||||
|
|
||||||
// Name of the sticker set to which the sticker belongs
|
|
||||||
SetName string `json:"set_name,omitempty"`
|
|
||||||
|
|
||||||
// Sticker width
|
// Sticker width
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
|
@ -2713,17 +2754,23 @@ type (
|
||||||
// Sticker height
|
// Sticker height
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
|
|
||||||
// File size
|
// true, if the sticker is animated
|
||||||
FileSize int `json:"file_size,omitempty"`
|
IsAnimated bool `json:"is_animated"`
|
||||||
|
|
||||||
// Sticker thumbnail in the .webp or .jpg format
|
// Sticker thumbnail in the .webp or .jpg format
|
||||||
Thumb *PhotoSize `json:"thumb,omitempty"`
|
Thumb *PhotoSize `json:"thumb,omitempty"`
|
||||||
|
|
||||||
|
// Emoji associated with the sticker
|
||||||
|
Emoji string `json:"emoji,omitempty"`
|
||||||
|
|
||||||
|
// Name of the sticker set to which the sticker belongs
|
||||||
|
SetName string `json:"set_name,omitempty"`
|
||||||
|
|
||||||
// For mask stickers, the position where the mask should be placed
|
// For mask stickers, the position where the mask should be placed
|
||||||
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
|
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
|
||||||
|
|
||||||
// true, if the sticker is animated
|
// File size
|
||||||
IsAnimated bool `json:"is_animated"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StickerSet represents a sticker set.
|
// StickerSet represents a sticker set.
|
||||||
|
|
Loading…
Reference in New Issue