Update to TDLib 1.8.12

This commit is contained in:
c0re100 2023-03-11 19:13:56 +08:00
parent 993b734553
commit 47887c89e1
No known key found for this signature in database
GPG key ID: 7C3B3004FE745AAF
4 changed files with 1615 additions and 211 deletions

View file

@ -1440,7 +1440,7 @@ type GetMessageViewersRequest struct {
}
// Returns viewers of a recent outgoing message in a basic group or a supergroup chat. For video notes and voice notes only users, opened content of the message, are returned. The method can be called if message.can_get_viewers == true
func (client *Client) GetMessageViewers(req *GetMessageViewersRequest) (*Users, error) {
func (client *Client) GetMessageViewers(req *GetMessageViewersRequest) (*MessageViewers, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getMessageViewers",
@ -1458,7 +1458,7 @@ func (client *Client) GetMessageViewers(req *GetMessageViewersRequest) (*Users,
return nil, buildResponseError(result.Data)
}
return UnmarshalUsers(result.Data)
return UnmarshalMessageViewers(result.Data)
}
type GetFileRequest struct {
@ -2842,7 +2842,7 @@ func (client *Client) GetMessageLinkInfo(req *GetMessageLinkInfoRequest) (*Messa
type TranslateTextRequest struct {
// Text to translate
Text *FormattedText `json:"text"`
// ISO language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"
// Language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"
ToLanguageCode string `json:"to_language_code"`
}
@ -2873,7 +2873,7 @@ type TranslateMessageTextRequest struct {
ChatId int64 `json:"chat_id"`
// Identifier of the message
MessageId int64 `json:"message_id"`
// ISO language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"
// Language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"
ToLanguageCode string `json:"to_language_code"`
}
@ -5104,16 +5104,14 @@ type AnswerInlineQueryRequest struct {
InlineQueryId JsonInt64 `json:"inline_query_id"`
// Pass true if results may be cached and returned only for the user that sent the query. By default, results may be returned to any user who sends the same query
IsPersonal bool `json:"is_personal"`
// Button to be shown above inline query results; pass null if none
Button *InlineQueryResultsButton `json:"button"`
// The results of the query
Results []InputInlineQueryResult `json:"results"`
// Allowed time to cache the results of the query, in seconds
CacheTime int32 `json:"cache_time"`
// Offset for the next inline query; pass an empty string if there are no more results
NextOffset string `json:"next_offset"`
// If non-empty, this text must be shown on the button that opens a private chat with the bot and sends a start message to the bot with the parameter switch_pm_parameter
SwitchPmText string `json:"switch_pm_text"`
// The parameter for the bot start message
SwitchPmParameter string `json:"switch_pm_parameter"`
}
// Sets the result of an inline query; for bots only
@ -5123,13 +5121,12 @@ func (client *Client) AnswerInlineQuery(req *AnswerInlineQueryRequest) (*Ok, err
Type: "answerInlineQuery",
},
Data: map[string]interface{}{
"inline_query_id": req.InlineQueryId,
"is_personal": req.IsPersonal,
"results": req.Results,
"cache_time": req.CacheTime,
"next_offset": req.NextOffset,
"switch_pm_text": req.SwitchPmText,
"switch_pm_parameter": req.SwitchPmParameter,
"inline_query_id": req.InlineQueryId,
"is_personal": req.IsPersonal,
"button": req.Button,
"results": req.Results,
"cache_time": req.CacheTime,
"next_offset": req.NextOffset,
},
})
if err != nil {
@ -5143,10 +5140,83 @@ func (client *Client) AnswerInlineQuery(req *AnswerInlineQueryRequest) (*Ok, err
return UnmarshalOk(result.Data)
}
type SearchWebAppRequest struct {
// Identifier of the target bot
BotUserId int64 `json:"bot_user_id"`
// Short name of the Web App
WebAppShortName string `json:"web_app_short_name"`
}
// Returns information about a Web App by its short name. Returns a 404 error if the Web App is not found
func (client *Client) SearchWebApp(req *SearchWebAppRequest) (*FoundWebApp, error) {
result, err := client.Send(Request{
meta: meta{
Type: "searchWebApp",
},
Data: map[string]interface{}{
"bot_user_id": req.BotUserId,
"web_app_short_name": req.WebAppShortName,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalFoundWebApp(result.Data)
}
type GetWebAppLinkUrlRequest struct {
// Identifier of the chat in which the link was clicked; pass 0 if none
ChatId int64 `json:"chat_id"`
// Identifier of the target bot
BotUserId int64 `json:"bot_user_id"`
// Short name of the Web App
WebAppShortName string `json:"web_app_short_name"`
// Start parameter from internalLinkTypeWebApp
StartParameter string `json:"start_parameter"`
// Preferred Web App theme; pass null to use the default theme
Theme *ThemeParameters `json:"theme"`
// Short name of the application; 0-64 English letters, digits, and underscores
ApplicationName string `json:"application_name"`
// Pass true if the current user allowed the bot to send them messages
AllowWriteAccess bool `json:"allow_write_access"`
}
// Returns an HTTPS URL of a Web App to open after a link of the type internalLinkTypeWebApp is clicked
func (client *Client) GetWebAppLinkUrl(req *GetWebAppLinkUrlRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getWebAppLinkUrl",
},
Data: map[string]interface{}{
"chat_id": req.ChatId,
"bot_user_id": req.BotUserId,
"web_app_short_name": req.WebAppShortName,
"start_parameter": req.StartParameter,
"theme": req.Theme,
"application_name": req.ApplicationName,
"allow_write_access": req.AllowWriteAccess,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
type GetWebAppUrlRequest struct {
// Identifier of the target bot
BotUserId int64 `json:"bot_user_id"`
// The URL from the keyboardButtonTypeWebApp button
// The URL from the keyboardButtonTypeWebApp or inlineQueryResultsButtonTypeWebApp button
Url string `json:"url"`
// Preferred Web App theme; pass null to use the default theme
Theme *ThemeParameters `json:"theme"`
@ -5154,7 +5224,7 @@ type GetWebAppUrlRequest struct {
ApplicationName string `json:"application_name"`
}
// Returns an HTTPS URL of a Web App to open after keyboardButtonTypeWebApp button is pressed
// Returns an HTTPS URL of a Web App to open after keyboardButtonTypeWebApp or inlineQueryResultsButtonTypeWebApp button is pressed
func (client *Client) GetWebAppUrl(req *GetWebAppUrlRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
@ -5696,11 +5766,11 @@ func (client *Client) CloseChat(req *CloseChatRequest) (*Ok, error) {
type ViewMessagesRequest struct {
// Chat identifier
ChatId int64 `json:"chat_id"`
// If not 0, a message thread identifier in which the messages are being viewed
MessageThreadId int64 `json:"message_thread_id"`
// The identifiers of the messages being viewed
MessageIds []int64 `json:"message_ids"`
// Pass true to mark as read the specified messages even the chat is closed
// Source of the message view
Source MessageSource `json:"source"`
// Pass true to mark as read the specified messages even the chat is closed; pass null to guess the source based on chat open state
ForceRead bool `json:"force_read"`
}
@ -5711,10 +5781,10 @@ func (client *Client) ViewMessages(req *ViewMessagesRequest) (*Ok, error) {
Type: "viewMessages",
},
Data: map[string]interface{}{
"chat_id": req.ChatId,
"message_thread_id": req.MessageThreadId,
"message_ids": req.MessageIds,
"force_read": req.ForceRead,
"chat_id": req.ChatId,
"message_ids": req.MessageIds,
"source": req.Source,
"force_read": req.ForceRead,
},
})
if err != nil {
@ -5786,6 +5856,35 @@ func (client *Client) ClickAnimatedEmojiMessage(req *ClickAnimatedEmojiMessageRe
return UnmarshalSticker(result.Data)
}
type GetInternalLinkRequest struct {
// Expected type of the link
Type InternalLinkType `json:"type"`
// Pass true to create an HTTPS link (only available for some link types); pass false to create a tg: link
IsHttp bool `json:"is_http"`
}
// Returns an HTTPS or a tg: link with the given type. Can be called before authorization
func (client *Client) GetInternalLink(req *GetInternalLinkRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getInternalLink",
},
Data: map[string]interface{}{
"type": req.Type,
"is_http": req.IsHttp,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
type GetInternalLinkTypeRequest struct {
// The link
Link string `json:"link"`
@ -5822,15 +5921,15 @@ func (client *Client) GetInternalLinkType(req *GetInternalLinkTypeRequest) (Inte
case TypeInternalLinkTypeBackground:
return UnmarshalInternalLinkTypeBackground(result.Data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(result.Data)
case TypeInternalLinkTypeBotStart:
return UnmarshalInternalLinkTypeBotStart(result.Data)
case TypeInternalLinkTypeBotStartInGroup:
return UnmarshalInternalLinkTypeBotStartInGroup(result.Data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(result.Data)
case TypeInternalLinkTypeChangePhoneNumber:
return UnmarshalInternalLinkTypeChangePhoneNumber(result.Data)
@ -5918,6 +6017,9 @@ func (client *Client) GetInternalLinkType(req *GetInternalLinkTypeRequest) (Inte
case TypeInternalLinkTypeVideoChat:
return UnmarshalInternalLinkTypeVideoChat(result.Data)
case TypeInternalLinkTypeWebApp:
return UnmarshalInternalLinkTypeWebApp(result.Data)
default:
return nil, errors.New("invalid type")
}
@ -6211,7 +6313,7 @@ func (client *Client) CreateSecretChat(req *CreateSecretChatRequest) (*Chat, err
}
type CreateNewBasicGroupChatRequest struct {
// Identifiers of users to be added to the basic group
// Identifiers of users to be added to the basic group; may be empty to create a basic group without other members
UserIds []int64 `json:"user_ids"`
// Title of the new basic group; 1-128 characters
Title string `json:"title"`
@ -12134,6 +12236,116 @@ func (client *Client) SetDefaultChannelAdministratorRights(req *SetDefaultChanne
return UnmarshalOk(result.Data)
}
type SetBotInfoDescriptionRequest struct {
// A two-letter ISO 639-1 language code. If empty, the description will be shown to all users, for which language there are no dedicated description
LanguageCode string `json:"language_code"`
// New bot's description on the specified language
Description string `json:"description"`
}
// Sets the text shown in the chat with the bot if the chat is empty; bots only
func (client *Client) SetBotInfoDescription(req *SetBotInfoDescriptionRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setBotInfoDescription",
},
Data: map[string]interface{}{
"language_code": req.LanguageCode,
"description": req.Description,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type GetBotInfoDescriptionRequest struct {
// A two-letter ISO 639-1 language code or an empty string
LanguageCode string `json:"language_code"`
}
// Returns the text shown in the chat with the bot if the chat is empty in the given language; bots only
func (client *Client) GetBotInfoDescription(req *GetBotInfoDescriptionRequest) (*Text, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getBotInfoDescription",
},
Data: map[string]interface{}{
"language_code": req.LanguageCode,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalText(result.Data)
}
type SetBotInfoShortDescriptionRequest struct {
// A two-letter ISO 639-1 language code. If empty, the short description will be shown to all users, for which language there are no dedicated description
LanguageCode string `json:"language_code"`
// New bot's short description on the specified language
ShortDescription string `json:"short_description"`
}
// Sets the text shown on the bot's profile page and sent together with the link when users share the bot; bots only
func (client *Client) SetBotInfoShortDescription(req *SetBotInfoShortDescriptionRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setBotInfoShortDescription",
},
Data: map[string]interface{}{
"language_code": req.LanguageCode,
"short_description": req.ShortDescription,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type GetBotInfoShortDescriptionRequest struct {
// A two-letter ISO 639-1 language code or an empty string
LanguageCode string `json:"language_code"`
}
// Returns the text shown on the bot's profile page and sent together with the link when users share the bot in the given language; bots only
func (client *Client) GetBotInfoShortDescription(req *GetBotInfoShortDescriptionRequest) (*Text, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getBotInfoShortDescription",
},
Data: map[string]interface{}{
"language_code": req.LanguageCode,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalText(result.Data)
}
// Returns all active sessions of the current user
func (client *Client) GetActiveSessions() (*Sessions, error) {
result, err := client.Send(Request{
@ -13379,7 +13591,7 @@ func (client *Client) SynchronizeLanguagePack(req *SynchronizeLanguagePackReques
}
type AddCustomServerLanguagePackRequest struct {
// Identifier of a language pack to be added; may be different from a name that is used in an "https://t.me/setlanguage/" link
// Identifier of a language pack to be added
LanguagePackId string `json:"language_pack_id"`
}
@ -14404,7 +14616,7 @@ type SetAutosaveSettingsRequest struct {
Settings *ScopeAutosaveSettings `json:"settings"`
}
// Sets autosave settings for the given scope
// Sets autosave settings for the given scope. The method is guaranteed to work only after at least one call to getAutosaveSettings
func (client *Client) SetAutosaveSettings(req *SetAutosaveSettingsRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -14426,7 +14638,7 @@ func (client *Client) SetAutosaveSettings(req *SetAutosaveSettingsRequest) (*Ok,
return UnmarshalOk(result.Data)
}
// Clears the list of all autosave settings exceptions
// Clears the list of all autosave settings exceptions. The method is guaranteed to work only after at least one call to getAutosaveSettings
func (client *Client) ClearAutosaveSettingsExceptions() (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -15067,8 +15279,10 @@ func (client *Client) SetBotUpdatesStatus(req *SetBotUpdatesStatusRequest) (*Ok,
type UploadStickerFileRequest struct {
// Sticker file owner; ignored for regular users
UserId int64 `json:"user_id"`
// Sticker file to upload
Sticker *InputSticker `json:"sticker"`
// Sticker format
StickerFormat StickerFormat `json:"sticker_format"`
// File file to upload; must fit in a 512x512 square. For WEBP stickers the file must be in WEBP or PNG format, which will be converted to WEBP server-side. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
Sticker InputFile `json:"sticker"`
}
// Uploads a file with a sticker; returns the uploaded file
@ -15078,8 +15292,9 @@ func (client *Client) UploadStickerFile(req *UploadStickerFileRequest) (*File, e
Type: "uploadStickerFile",
},
Data: map[string]interface{}{
"user_id": req.UserId,
"sticker": req.Sticker,
"user_id": req.UserId,
"sticker_format": req.StickerFormat,
"sticker": req.Sticker,
},
})
if err != nil {
@ -15164,8 +15379,12 @@ type CreateNewStickerSetRequest struct {
Title string `json:"title"`
// Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive) for bots; 1-64 characters
Name string `json:"name"`
// Format of the stickers in the set
StickerFormat StickerFormat `json:"sticker_format"`
// Type of the stickers in the set
StickerType StickerType `json:"sticker_type"`
// Pass true if stickers in the sticker set must be repainted; for custom emoji sticker sets only
NeedsRepainting bool `json:"needs_repainting"`
// List of stickers to be added to the set; must be non-empty. All stickers must have the same format. For TGS stickers, uploadStickerFile must be used before the sticker is shown
Stickers []*InputSticker `json:"stickers"`
// Source of the sticker set; may be empty if unknown
@ -15179,12 +15398,14 @@ func (client *Client) CreateNewStickerSet(req *CreateNewStickerSetRequest) (*Sti
Type: "createNewStickerSet",
},
Data: map[string]interface{}{
"user_id": req.UserId,
"title": req.Title,
"name": req.Name,
"sticker_type": req.StickerType,
"stickers": req.Stickers,
"source": req.Source,
"user_id": req.UserId,
"title": req.Title,
"name": req.Name,
"sticker_format": req.StickerFormat,
"sticker_type": req.StickerType,
"needs_repainting": req.NeedsRepainting,
"stickers": req.Stickers,
"source": req.Source,
},
})
if err != nil {
@ -15207,8 +15428,8 @@ type AddStickerToSetRequest struct {
Sticker *InputSticker `json:"sticker"`
}
// Adds a new sticker to a set; for bots only. Returns the sticker set
func (client *Client) AddStickerToSet(req *AddStickerToSetRequest) (*StickerSet, error) {
// Adds a new sticker to a set; for bots only
func (client *Client) AddStickerToSet(req *AddStickerToSetRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "addStickerToSet",
@ -15227,7 +15448,7 @@ func (client *Client) AddStickerToSet(req *AddStickerToSetRequest) (*StickerSet,
return nil, buildResponseError(result.Data)
}
return UnmarshalStickerSet(result.Data)
return UnmarshalOk(result.Data)
}
type SetStickerSetThumbnailRequest struct {
@ -15239,8 +15460,8 @@ type SetStickerSetThumbnailRequest struct {
Thumbnail InputFile `json:"thumbnail"`
}
// Sets a sticker set thumbnail; for bots only. Returns the sticker set
func (client *Client) SetStickerSetThumbnail(req *SetStickerSetThumbnailRequest) (*StickerSet, error) {
// Sets a sticker set thumbnail; for bots only
func (client *Client) SetStickerSetThumbnail(req *SetStickerSetThumbnailRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setStickerSetThumbnail",
@ -15259,7 +15480,91 @@ func (client *Client) SetStickerSetThumbnail(req *SetStickerSetThumbnailRequest)
return nil, buildResponseError(result.Data)
}
return UnmarshalStickerSet(result.Data)
return UnmarshalOk(result.Data)
}
type SetCustomEmojiStickerSetThumbnailRequest struct {
// Sticker set name
Name string `json:"name"`
// Identifier of the custom emoji from the sticker set, which will be set as sticker set thumbnail; pass 0 to remove the sticker set thumbnail
CustomEmojiId JsonInt64 `json:"custom_emoji_id"`
}
// Sets a custom emoji sticker set thumbnail; for bots only
func (client *Client) SetCustomEmojiStickerSetThumbnail(req *SetCustomEmojiStickerSetThumbnailRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setCustomEmojiStickerSetThumbnail",
},
Data: map[string]interface{}{
"name": req.Name,
"custom_emoji_id": req.CustomEmojiId,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetStickerSetTitleRequest struct {
// Sticker set name
Name string `json:"name"`
// New sticker set title
Title string `json:"title"`
}
// Sets a sticker set title; for bots only
func (client *Client) SetStickerSetTitle(req *SetStickerSetTitleRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setStickerSetTitle",
},
Data: map[string]interface{}{
"name": req.Name,
"title": req.Title,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type DeleteStickerSetRequest struct {
// Sticker set name
Name string `json:"name"`
}
// Deleted a sticker set; for bots only
func (client *Client) DeleteStickerSet(req *DeleteStickerSetRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "deleteStickerSet",
},
Data: map[string]interface{}{
"name": req.Name,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetStickerPositionInSetRequest struct {
@ -15317,6 +15622,93 @@ func (client *Client) RemoveStickerFromSet(req *RemoveStickerFromSetRequest) (*O
return UnmarshalOk(result.Data)
}
type SetStickerEmojisRequest struct {
// Sticker
Sticker InputFile `json:"sticker"`
// New string with 1-20 emoji corresponding to the sticker
Emojis string `json:"emojis"`
}
// Changes the list of emoji corresponding to a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot
func (client *Client) SetStickerEmojis(req *SetStickerEmojisRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setStickerEmojis",
},
Data: map[string]interface{}{
"sticker": req.Sticker,
"emojis": req.Emojis,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetStickerKeywordsRequest struct {
// Sticker
Sticker InputFile `json:"sticker"`
// List of up to 20 keywords with total length up to 64 characters, which can be used to find the sticker
Keywords []string `json:"keywords"`
}
// Changes the list of keywords of a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot
func (client *Client) SetStickerKeywords(req *SetStickerKeywordsRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setStickerKeywords",
},
Data: map[string]interface{}{
"sticker": req.Sticker,
"keywords": req.Keywords,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetStickerMaskPositionRequest struct {
// Sticker
Sticker InputFile `json:"sticker"`
// Position where the mask is placed; pass null to remove mask position
MaskPosition *MaskPosition `json:"mask_position"`
}
// Changes the mask position of a mask sticker; for bots only. The sticker must belong to a mask sticker set created by the bot
func (client *Client) SetStickerMaskPosition(req *SetStickerMaskPositionRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setStickerMaskPosition",
},
Data: map[string]interface{}{
"sticker": req.Sticker,
"mask_position": req.MaskPosition,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type GetMapThumbnailFileRequest struct {
// Location of the map center
Location *Location `json:"location"`
@ -15792,25 +16184,6 @@ func (client *Client) GetPhoneNumberInfoSync(req *GetPhoneNumberInfoSyncRequest)
return GetPhoneNumberInfoSync(req)
}
// Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
func (client *Client) GetApplicationDownloadLink() (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getApplicationDownloadLink",
},
Data: map[string]interface{}{},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
type GetDeepLinkInfoRequest struct {
// The link
Link string `json:"link"`
@ -15877,6 +16250,32 @@ func (client *Client) GetApplicationConfig() (JsonValue, error) {
}
}
type AddApplicationChangelogRequest struct {
// The previous application version
PreviousApplicationVersion string `json:"previous_application_version"`
}
// Adds server-provided application changelog as messages to the chat 777000 (Telegram); for official applications only
func (client *Client) AddApplicationChangelog(req *AddApplicationChangelogRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "addApplicationChangelog",
},
Data: map[string]interface{}{
"previous_application_version": req.PreviousApplicationVersion,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SaveApplicationLogEventRequest struct {
// Event type
Type string `json:"type"`
@ -15909,6 +16308,25 @@ func (client *Client) SaveApplicationLogEvent(req *SaveApplicationLogEventReques
return UnmarshalOk(result.Data)
}
// Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
func (client *Client) GetApplicationDownloadLink() (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getApplicationDownloadLink",
},
Data: map[string]interface{}{},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
type AddProxyRequest struct {
// Proxy server IP address
Server string `json:"server"`
@ -17008,6 +17426,9 @@ func (client *Client) TestUseUpdate() (Update, error) {
case TypeUpdateSuggestedActions:
return UnmarshalUpdateSuggestedActions(result.Data)
case TypeUpdateAddChatMembersPrivacyForbidden:
return UnmarshalUpdateAddChatMembersPrivacyForbidden(result.Data)
case TypeUpdateAutosaveSettings:
return UnmarshalUpdateAutosaveSettings(result.Data)

File diff suppressed because it is too large Load diff

View file

@ -877,6 +877,61 @@ func UnmarshalListOfMessageSendingState(dataList []json.RawMessage) ([]MessageSe
return list, nil
}
func UnmarshalMessageSource(data json.RawMessage) (MessageSource, error) {
var meta meta
err := json.Unmarshal(data, &meta)
if err != nil {
return nil, err
}
switch meta.Type {
case TypeMessageSourceChatHistory:
return UnmarshalMessageSourceChatHistory(data)
case TypeMessageSourceMessageThreadHistory:
return UnmarshalMessageSourceMessageThreadHistory(data)
case TypeMessageSourceForumTopicHistory:
return UnmarshalMessageSourceForumTopicHistory(data)
case TypeMessageSourceHistoryPreview:
return UnmarshalMessageSourceHistoryPreview(data)
case TypeMessageSourceChatList:
return UnmarshalMessageSourceChatList(data)
case TypeMessageSourceSearch:
return UnmarshalMessageSourceSearch(data)
case TypeMessageSourceChatEventLog:
return UnmarshalMessageSourceChatEventLog(data)
case TypeMessageSourceNotification:
return UnmarshalMessageSourceNotification(data)
case TypeMessageSourceOther:
return UnmarshalMessageSourceOther(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
}
func UnmarshalListOfMessageSource(dataList []json.RawMessage) ([]MessageSource, error) {
list := []MessageSource{}
for _, data := range dataList {
entity, err := UnmarshalMessageSource(data)
if err != nil {
return nil, err
}
list = append(list, entity)
}
return list, nil
}
func UnmarshalNotificationSettingsScope(data json.RawMessage) (NotificationSettingsScope, error) {
var meta meta
@ -3142,6 +3197,40 @@ func UnmarshalListOfInlineQueryResult(dataList []json.RawMessage) ([]InlineQuery
return list, nil
}
func UnmarshalInlineQueryResultsButtonType(data json.RawMessage) (InlineQueryResultsButtonType, error) {
var meta meta
err := json.Unmarshal(data, &meta)
if err != nil {
return nil, err
}
switch meta.Type {
case TypeInlineQueryResultsButtonTypeStartBot:
return UnmarshalInlineQueryResultsButtonTypeStartBot(data)
case TypeInlineQueryResultsButtonTypeWebApp:
return UnmarshalInlineQueryResultsButtonTypeWebApp(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
}
func UnmarshalListOfInlineQueryResultsButtonType(dataList []json.RawMessage) ([]InlineQueryResultsButtonType, error) {
list := []InlineQueryResultsButtonType{}
for _, data := range dataList {
entity, err := UnmarshalInlineQueryResultsButtonType(data)
if err != nil {
return nil, err
}
list = append(list, entity)
}
return list, nil
}
func UnmarshalCallbackQueryPayload(data json.RawMessage) (CallbackQueryPayload, error) {
var meta meta
@ -4536,15 +4625,15 @@ func UnmarshalInternalLinkType(data json.RawMessage) (InternalLinkType, error) {
case TypeInternalLinkTypeBackground:
return UnmarshalInternalLinkTypeBackground(data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(data)
case TypeInternalLinkTypeBotStart:
return UnmarshalInternalLinkTypeBotStart(data)
case TypeInternalLinkTypeBotStartInGroup:
return UnmarshalInternalLinkTypeBotStartInGroup(data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(data)
case TypeInternalLinkTypeChangePhoneNumber:
return UnmarshalInternalLinkTypeChangePhoneNumber(data)
@ -4632,6 +4721,9 @@ func UnmarshalInternalLinkType(data json.RawMessage) (InternalLinkType, error) {
case TypeInternalLinkTypeVideoChat:
return UnmarshalInternalLinkTypeVideoChat(data)
case TypeInternalLinkTypeWebApp:
return UnmarshalInternalLinkTypeWebApp(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
@ -5547,6 +5639,9 @@ func UnmarshalUpdate(data json.RawMessage) (Update, error) {
case TypeUpdateSuggestedActions:
return UnmarshalUpdateSuggestedActions(data)
case TypeUpdateAddChatMembersPrivacyForbidden:
return UnmarshalUpdateAddChatMembersPrivacyForbidden(data)
case TypeUpdateAutosaveSettings:
return UnmarshalUpdateAutosaveSettings(data)
@ -6298,6 +6393,14 @@ func UnmarshalGame(data json.RawMessage) (*Game, error) {
return &resp, err
}
func UnmarshalWebApp(data json.RawMessage) (*WebApp, error) {
var resp WebApp
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalPoll(data json.RawMessage) (*Poll, error) {
var resp Poll
@ -6938,6 +7041,22 @@ func UnmarshalChatMessageSenders(data json.RawMessage) (*ChatMessageSenders, err
return &resp, err
}
func UnmarshalMessageViewer(data json.RawMessage) (*MessageViewer, error) {
var resp MessageViewer
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageViewers(data json.RawMessage) (*MessageViewers, error) {
var resp MessageViewers
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageForwardOriginUser(data json.RawMessage) (*MessageForwardOriginUser, error) {
var resp MessageForwardOriginUser
@ -7114,6 +7233,78 @@ func UnmarshalMessageCalendar(data json.RawMessage) (*MessageCalendar, error) {
return &resp, err
}
func UnmarshalMessageSourceChatHistory(data json.RawMessage) (*MessageSourceChatHistory, error) {
var resp MessageSourceChatHistory
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceMessageThreadHistory(data json.RawMessage) (*MessageSourceMessageThreadHistory, error) {
var resp MessageSourceMessageThreadHistory
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceForumTopicHistory(data json.RawMessage) (*MessageSourceForumTopicHistory, error) {
var resp MessageSourceForumTopicHistory
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceHistoryPreview(data json.RawMessage) (*MessageSourceHistoryPreview, error) {
var resp MessageSourceHistoryPreview
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceChatList(data json.RawMessage) (*MessageSourceChatList, error) {
var resp MessageSourceChatList
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceSearch(data json.RawMessage) (*MessageSourceSearch, error) {
var resp MessageSourceSearch
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceChatEventLog(data json.RawMessage) (*MessageSourceChatEventLog, error) {
var resp MessageSourceChatEventLog
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceNotification(data json.RawMessage) (*MessageSourceNotification, error) {
var resp MessageSourceNotification
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageSourceOther(data json.RawMessage) (*MessageSourceOther, error) {
var resp MessageSourceOther
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalSponsoredMessage(data json.RawMessage) (*SponsoredMessage, error) {
var resp SponsoredMessage
@ -7642,6 +7833,14 @@ func UnmarshalLoginUrlInfoRequestConfirmation(data json.RawMessage) (*LoginUrlIn
return &resp, err
}
func UnmarshalFoundWebApp(data json.RawMessage) (*FoundWebApp, error) {
var resp FoundWebApp
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalWebAppInfo(data json.RawMessage) (*WebAppInfo, error) {
var resp WebAppInfo
@ -10842,6 +11041,30 @@ func UnmarshalInlineQueryResultVoiceNote(data json.RawMessage) (*InlineQueryResu
return &resp, err
}
func UnmarshalInlineQueryResultsButtonTypeStartBot(data json.RawMessage) (*InlineQueryResultsButtonTypeStartBot, error) {
var resp InlineQueryResultsButtonTypeStartBot
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInlineQueryResultsButtonTypeWebApp(data json.RawMessage) (*InlineQueryResultsButtonTypeWebApp, error) {
var resp InlineQueryResultsButtonTypeWebApp
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInlineQueryResultsButton(data json.RawMessage) (*InlineQueryResultsButton, error) {
var resp InlineQueryResultsButton
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInlineQueryResults(data json.RawMessage) (*InlineQueryResults, error) {
var resp InlineQueryResults
@ -12866,6 +13089,14 @@ func UnmarshalInternalLinkTypeBackground(data json.RawMessage) (*InternalLinkTyp
return &resp, err
}
func UnmarshalInternalLinkTypeBotAddToChannel(data json.RawMessage) (*InternalLinkTypeBotAddToChannel, error) {
var resp InternalLinkTypeBotAddToChannel
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInternalLinkTypeBotStart(data json.RawMessage) (*InternalLinkTypeBotStart, error) {
var resp InternalLinkTypeBotStart
@ -12882,14 +13113,6 @@ func UnmarshalInternalLinkTypeBotStartInGroup(data json.RawMessage) (*InternalLi
return &resp, err
}
func UnmarshalInternalLinkTypeBotAddToChannel(data json.RawMessage) (*InternalLinkTypeBotAddToChannel, error) {
var resp InternalLinkTypeBotAddToChannel
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInternalLinkTypeChangePhoneNumber(data json.RawMessage) (*InternalLinkTypeChangePhoneNumber, error) {
var resp InternalLinkTypeChangePhoneNumber
@ -13122,6 +13345,14 @@ func UnmarshalInternalLinkTypeVideoChat(data json.RawMessage) (*InternalLinkType
return &resp, err
}
func UnmarshalInternalLinkTypeWebApp(data json.RawMessage) (*InternalLinkTypeWebApp, error) {
var resp InternalLinkTypeWebApp
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMessageLink(data json.RawMessage) (*MessageLink, error) {
var resp MessageLink
@ -14698,6 +14929,14 @@ func UnmarshalUpdateSuggestedActions(data json.RawMessage) (*UpdateSuggestedActi
return &resp, err
}
func UnmarshalUpdateAddChatMembersPrivacyForbidden(data json.RawMessage) (*UpdateAddChatMembersPrivacyForbidden, error) {
var resp UpdateAddChatMembersPrivacyForbidden
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalUpdateAutosaveSettings(data json.RawMessage) (*UpdateAutosaveSettings, error) {
var resp UpdateAutosaveSettings
@ -15169,6 +15408,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeGame:
return UnmarshalGame(data)
case TypeWebApp:
return UnmarshalWebApp(data)
case TypePoll:
return UnmarshalPoll(data)
@ -15409,6 +15651,12 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeChatMessageSenders:
return UnmarshalChatMessageSenders(data)
case TypeMessageViewer:
return UnmarshalMessageViewer(data)
case TypeMessageViewers:
return UnmarshalMessageViewers(data)
case TypeMessageForwardOriginUser:
return UnmarshalMessageForwardOriginUser(data)
@ -15475,6 +15723,33 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeMessageCalendar:
return UnmarshalMessageCalendar(data)
case TypeMessageSourceChatHistory:
return UnmarshalMessageSourceChatHistory(data)
case TypeMessageSourceMessageThreadHistory:
return UnmarshalMessageSourceMessageThreadHistory(data)
case TypeMessageSourceForumTopicHistory:
return UnmarshalMessageSourceForumTopicHistory(data)
case TypeMessageSourceHistoryPreview:
return UnmarshalMessageSourceHistoryPreview(data)
case TypeMessageSourceChatList:
return UnmarshalMessageSourceChatList(data)
case TypeMessageSourceSearch:
return UnmarshalMessageSourceSearch(data)
case TypeMessageSourceChatEventLog:
return UnmarshalMessageSourceChatEventLog(data)
case TypeMessageSourceNotification:
return UnmarshalMessageSourceNotification(data)
case TypeMessageSourceOther:
return UnmarshalMessageSourceOther(data)
case TypeSponsoredMessage:
return UnmarshalSponsoredMessage(data)
@ -15673,6 +15948,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeLoginUrlInfoRequestConfirmation:
return UnmarshalLoginUrlInfoRequestConfirmation(data)
case TypeFoundWebApp:
return UnmarshalFoundWebApp(data)
case TypeWebAppInfo:
return UnmarshalWebAppInfo(data)
@ -16873,6 +17151,15 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeInlineQueryResultVoiceNote:
return UnmarshalInlineQueryResultVoiceNote(data)
case TypeInlineQueryResultsButtonTypeStartBot:
return UnmarshalInlineQueryResultsButtonTypeStartBot(data)
case TypeInlineQueryResultsButtonTypeWebApp:
return UnmarshalInlineQueryResultsButtonTypeWebApp(data)
case TypeInlineQueryResultsButton:
return UnmarshalInlineQueryResultsButton(data)
case TypeInlineQueryResults:
return UnmarshalInlineQueryResults(data)
@ -17632,15 +17919,15 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeInternalLinkTypeBackground:
return UnmarshalInternalLinkTypeBackground(data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(data)
case TypeInternalLinkTypeBotStart:
return UnmarshalInternalLinkTypeBotStart(data)
case TypeInternalLinkTypeBotStartInGroup:
return UnmarshalInternalLinkTypeBotStartInGroup(data)
case TypeInternalLinkTypeBotAddToChannel:
return UnmarshalInternalLinkTypeBotAddToChannel(data)
case TypeInternalLinkTypeChangePhoneNumber:
return UnmarshalInternalLinkTypeChangePhoneNumber(data)
@ -17728,6 +18015,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeInternalLinkTypeVideoChat:
return UnmarshalInternalLinkTypeVideoChat(data)
case TypeInternalLinkTypeWebApp:
return UnmarshalInternalLinkTypeWebApp(data)
case TypeMessageLink:
return UnmarshalMessageLink(data)
@ -18319,6 +18609,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeUpdateSuggestedActions:
return UnmarshalUpdateSuggestedActions(data)
case TypeUpdateAddChatMembersPrivacyForbidden:
return UnmarshalUpdateAddChatMembersPrivacyForbidden(data)
case TypeUpdateAutosaveSettings:
return UnmarshalUpdateAutosaveSettings(data)