update for TDLib v1.5.0

This commit is contained in:
Aleksandr Zelenin 2019-09-10 15:36:54 +03:00
parent 7f5ecc75f7
commit bb283b57fc
10 changed files with 3191 additions and 689 deletions

View file

@ -40,8 +40,6 @@ type clientAuthorizer struct {
PhoneNumber chan string
Code chan string
State chan AuthorizationState
FirstName chan string
LastName chan string
Password chan string
}
@ -51,8 +49,6 @@ func ClientAuthorizer() *clientAuthorizer {
PhoneNumber: make(chan string, 1),
Code: make(chan string, 1),
State: make(chan AuthorizationState, 10),
FirstName: make(chan string, 1),
LastName: make(chan string, 1),
Password: make(chan string, 1),
}
}
@ -73,20 +69,24 @@ func (stateHandler *clientAuthorizer) Handle(client *Client, state Authorization
case TypeAuthorizationStateWaitPhoneNumber:
_, err := client.SetAuthenticationPhoneNumber(&SetAuthenticationPhoneNumberRequest{
PhoneNumber: <-stateHandler.PhoneNumber,
AllowFlashCall: false,
IsCurrentPhoneNumber: false,
PhoneNumber: <-stateHandler.PhoneNumber,
Settings: &PhoneNumberAuthenticationSettings{
AllowFlashCall: false,
IsCurrentPhoneNumber: false,
AllowSmsRetrieverApi: false,
},
})
return err
case TypeAuthorizationStateWaitCode:
_, err := client.CheckAuthenticationCode(&CheckAuthenticationCodeRequest{
Code: <-stateHandler.Code,
FirstName: <-stateHandler.FirstName,
LastName: <-stateHandler.LastName,
Code: <-stateHandler.Code,
})
return err
case TypeAuthorizationStateWaitRegistration:
return ErrNotSupportedAuthorizationState
case TypeAuthorizationStateWaitPassword:
_, err := client.CheckAuthenticationPassword(&CheckAuthenticationPasswordRequest{
Password: <-stateHandler.Password,
@ -114,8 +114,6 @@ func (stateHandler *clientAuthorizer) Close() {
close(stateHandler.PhoneNumber)
close(stateHandler.Code)
close(stateHandler.State)
close(stateHandler.FirstName)
close(stateHandler.LastName)
close(stateHandler.Password)
}
@ -137,25 +135,11 @@ func CliInteractor(clientAuthorizer *clientAuthorizer) {
case TypeAuthorizationStateWaitCode:
var code string
var firstName string
var lastName string
fmt.Println("Enter code: ")
fmt.Scanln(&code)
if !state.(*AuthorizationStateWaitCode).IsRegistered {
fmt.Println("Phone number is not registered.")
fmt.Println("Enter first name: ")
fmt.Scanln(&firstName)
fmt.Println("Enter last name: ")
fmt.Scanln(&lastName)
}
clientAuthorizer.Code <- code
clientAuthorizer.FirstName <- firstName
clientAuthorizer.LastName <- lastName
case TypeAuthorizationStateWaitPassword:
fmt.Println("Enter password: ")

View file

@ -42,6 +42,12 @@ func WithProxy(req *AddProxyRequest) Option {
}
}
func WithLogVerbosity(req *SetLogVerbosityLevelRequest) Option {
return func(client *Client) {
client.SetLogVerbosityLevel(req)
}
}
func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...Option) (*Client, error) {
catchersListener := make(chan *Response, 1000)

View file

@ -35,6 +35,9 @@ func (client *Client) GetAuthorizationState() (AuthorizationState, error) {
case TypeAuthorizationStateWaitCode:
return UnmarshalAuthorizationStateWaitCode(result.Data)
case TypeAuthorizationStateWaitRegistration:
return UnmarshalAuthorizationStateWaitRegistration(result.Data)
case TypeAuthorizationStateWaitPassword:
return UnmarshalAuthorizationStateWaitPassword(result.Data)
@ -110,22 +113,19 @@ func (client *Client) CheckDatabaseEncryptionKey(req *CheckDatabaseEncryptionKey
type SetAuthenticationPhoneNumberRequest struct {
// The phone number of the user, in international format
PhoneNumber string `json:"phone_number"`
// Pass true if the authentication code may be sent via flash call to the specified phone number
AllowFlashCall bool `json:"allow_flash_call"`
// Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
IsCurrentPhoneNumber bool `json:"is_current_phone_number"`
// Settings for the authentication of the user's phone number
Settings *PhoneNumberAuthenticationSettings `json:"settings"`
}
// Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitPhoneNumber
// Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitCode or authorizationStateWaitPassword
func (client *Client) SetAuthenticationPhoneNumber(req *SetAuthenticationPhoneNumberRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setAuthenticationPhoneNumber",
},
Data: map[string]interface{}{
"phone_number": req.PhoneNumber,
"allow_flash_call": req.AllowFlashCall,
"is_current_phone_number": req.IsCurrentPhoneNumber,
"phone_number": req.PhoneNumber,
"settings": req.Settings,
},
})
if err != nil {
@ -161,10 +161,6 @@ func (client *Client) ResendAuthenticationCode() (*Ok, error) {
type CheckAuthenticationCodeRequest struct {
// The verification code received via SMS, Telegram message, phone call, or flash call
Code string `json:"code"`
// If the user is not yet registered, the first name of the user; 1-64 characters. You can also pass an empty string for unregistered user there to check verification code validness. In the latter case PHONE_NUMBER_UNOCCUPIED error will be returned for a valid code
FirstName string `json:"first_name"`
// If the user is not yet registered; the last name of the user; optional; 0-64 characters
LastName string `json:"last_name"`
}
// Checks the authentication code. Works only when the current authorization state is authorizationStateWaitCode
@ -174,7 +170,34 @@ func (client *Client) CheckAuthenticationCode(req *CheckAuthenticationCodeReques
Type: "checkAuthenticationCode",
},
Data: map[string]interface{}{
"code": req.Code,
"code": req.Code,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type RegisterUserRequest struct {
// The first name of the user; 1-64 characters
FirstName string `json:"first_name"`
// The last name of the user; 0-64 characters
LastName string `json:"last_name"`
}
// Finishes user registration. Works only when the current authorization state is authorizationStateWaitRegistration
func (client *Client) RegisterUser(req *RegisterUserRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "registerUser",
},
Data: map[string]interface{}{
"first_name": req.FirstName,
"last_name": req.LastName,
},
@ -479,7 +502,7 @@ type SetRecoveryEmailAddressRequest struct {
NewRecoveryEmailAddress string `json:"new_recovery_email_address"`
}
// Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation
// Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed. If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation
func (client *Client) SetRecoveryEmailAddress(req *SetRecoveryEmailAddressRequest) (*PasswordState, error) {
result, err := client.Send(Request{
meta: meta{
@ -1072,7 +1095,7 @@ type GetChatsRequest struct {
Limit int32 `json:"limit"`
}
// Returns an ordered list of chats. Chats are sorted by the pair (order, chat_id) in decreasing order. (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed 64-bit number 9223372036854775807 == 2^63 - 1). For optimal performance the number of returned chats is chosen by the library.
// Returns an ordered list of chats. Chats are sorted by the pair (order, chat_id) in decreasing order. (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed 64-bit number 9223372036854775807 == 2^63 - 1). For optimal performance the number of returned chats is chosen by the library
func (client *Client) GetChats(req *GetChatsRequest) (*Chats, error) {
result, err := client.Send(Request{
meta: meta{
@ -1381,7 +1404,7 @@ func (client *Client) CheckChatUsername(req *CheckChatUsernameRequest) (CheckCha
}
}
// Returns a list of public chats created by the user
// Returns a list of public chats with username created by the user
func (client *Client) GetCreatedPublicChats() (*Chats, error) {
result, err := client.Send(Request{
meta: meta{
@ -1830,7 +1853,7 @@ type GetPublicMessageLinkRequest struct {
ForAlbum bool `json:"for_album"`
}
// Returns a public HTTPS link to a message. Available only for messages in public supergroups and channels
// Returns a public HTTPS link to a message. Available only for messages in supergroups and channels with username
func (client *Client) GetPublicMessageLink(req *GetPublicMessageLinkRequest) (*PublicMessageLink, error) {
result, err := client.Send(Request{
meta: meta{
@ -1882,6 +1905,32 @@ func (client *Client) GetMessageLink(req *GetMessageLinkRequest) (*HttpUrl, erro
return UnmarshalHttpUrl(result.Data)
}
type GetMessageLinkInfoRequest struct {
// The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or "https://t.me/username/...", or "tg://resolve?..."
Url string `json:"url"`
}
// Returns information about a public or private message link
func (client *Client) GetMessageLinkInfo(req *GetMessageLinkInfoRequest) (*MessageLinkInfo, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getMessageLinkInfo",
},
Data: map[string]interface{}{
"url": req.Url,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalMessageLinkInfo(result.Data)
}
type SendMessageRequest struct {
// Target chat
ChatId int64 `json:"chat_id"`
@ -1966,7 +2015,7 @@ type SendBotStartMessageRequest struct {
BotUserId int32 `json:"bot_user_id"`
// Identifier of the target chat
ChatId int64 `json:"chat_id"`
// A hidden parameter sent to the bot for deep linking purposes (https://api.telegram.org/bots#deep-linking)
// A hidden parameter sent to the bot for deep linking purposes (https://core.telegram.org/bots#deep-linking)
Parameter string `json:"parameter"`
}
@ -2046,10 +2095,14 @@ type ForwardMessagesRequest struct {
MessageIds []int64 `json:"message_ids"`
// Pass true to disable notification for the message, doesn't work if messages are forwarded to a secret chat
DisableNotification bool `json:"disable_notification"`
// Pass true if the message is sent from the background
// Pass true if the messages are sent from the background
FromBackground bool `json:"from_background"`
// True, if the messages should be grouped into an album after forwarding. For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages
AsAlbum bool `json:"as_album"`
// True, if content of the messages needs to be copied without links to the original messages. Always true if the messages are forwarded to a secret chat
SendCopy bool `json:"send_copy"`
// True, if media captions of message copies needs to be removed. Ignored if send_copy is false
RemoveCaption bool `json:"remove_caption"`
}
// Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message
@ -2065,6 +2118,37 @@ func (client *Client) ForwardMessages(req *ForwardMessagesRequest) (*Messages, e
"disable_notification": req.DisableNotification,
"from_background": req.FromBackground,
"as_album": req.AsAlbum,
"send_copy": req.SendCopy,
"remove_caption": req.RemoveCaption,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalMessages(result.Data)
}
type ResendMessagesRequest struct {
// Identifier of the chat to send messages
ChatId int64 `json:"chat_id"`
// Identifiers of the messages to resend. Message identifiers must be in a strictly increasing order
MessageIds []int64 `json:"message_ids"`
}
// Resends messages which failed to send. Can be called only for messages for which messageSendingStateFailed.can_retry is true and after specified in messageSendingStateFailed.retry_after time passed. If a message is re-sent, the corresponding failed to send message is deleted. Returns the sent messages in the same order as the message identifiers passed in message_ids. If a message can't be re-sent, null will be returned instead of the message
func (client *Client) ResendMessages(req *ResendMessagesRequest) (*Messages, error) {
result, err := client.Send(Request{
meta: meta{
Type: "resendMessages",
},
Data: map[string]interface{}{
"chat_id": req.ChatId,
"message_ids": req.MessageIds,
},
})
if err != nil {
@ -3633,7 +3717,7 @@ type UpgradeBasicGroupChatToSupergroupChatRequest struct {
ChatId int64 `json:"chat_id"`
}
// Creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and messageChatUpgradeFrom. Deactivates the original basic group
// Creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and messageChatUpgradeFrom; requires creator privileges. Deactivates the original basic group
func (client *Client) UpgradeBasicGroupChatToSupergroupChat(req *UpgradeBasicGroupChatToSupergroupChatRequest) (*Chat, error) {
result, err := client.Send(Request{
meta: meta{
@ -3661,7 +3745,7 @@ type SetChatTitleRequest struct {
Title string `json:"title"`
}
// Changes the chat title. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The title will not be changed until the request to the server has been completed
// Changes the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info rights. The title will not be changed until the request to the server has been completed
func (client *Client) SetChatTitle(req *SetChatTitleRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -3690,7 +3774,7 @@ type SetChatPhotoRequest struct {
Photo InputFile `json:"photo"`
}
// Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The photo will not be changed before request to the server has been completed
// Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires can_change_info rights. The photo will not be changed before request to the server has been completed
func (client *Client) SetChatPhoto(req *SetChatPhotoRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -3712,6 +3796,35 @@ func (client *Client) SetChatPhoto(req *SetChatPhotoRequest) (*Ok, error) {
return UnmarshalOk(result.Data)
}
type SetChatPermissionsRequest struct {
// Chat identifier
ChatId int64 `json:"chat_id"`
// New non-administrator members permissions in the chat
Permissions *ChatPermissions `json:"permissions"`
}
// Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right
func (client *Client) SetChatPermissions(req *SetChatPermissionsRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setChatPermissions",
},
Data: map[string]interface{}{
"chat_id": req.ChatId,
"permissions": req.Permissions,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetChatDraftMessageRequest struct {
// Chat identifier
ChatId int64 `json:"chat_id"`
@ -3886,6 +3999,35 @@ func (client *Client) SetChatClientData(req *SetChatClientDataRequest) (*Ok, err
return UnmarshalOk(result.Data)
}
type SetChatDescriptionRequest struct {
// Identifier of the chat
ChatId int64 `json:"chat_id"`
// New chat description; 0-255 characters
Description string `json:"description"`
}
// Changes information about a chat. Available for basic groups, supergroups, and channels. Requires can_change_info rights
func (client *Client) SetChatDescription(req *SetChatDescriptionRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setChatDescription",
},
Data: map[string]interface{}{
"chat_id": req.ChatId,
"description": req.Description,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type PinChatMessageRequest struct {
// Identifier of the chat
ChatId int64 `json:"chat_id"`
@ -3895,7 +4037,7 @@ type PinChatMessageRequest struct {
DisableNotification bool `json:"disable_notification"`
}
// Pins a message in a chat; requires appropriate administrator rights in the group or channel
// Pins a message in a chat; requires can_pin_messages rights
func (client *Client) PinChatMessage(req *PinChatMessageRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -3923,7 +4065,7 @@ type UnpinChatMessageRequest struct {
ChatId int64 `json:"chat_id"`
}
// Removes the pinned message from a chat; requires appropriate administrator rights in the group or channel
// Removes the pinned message from a chat; requires can_pin_messages rights in the group or channel
func (client *Client) UnpinChatMessage(req *UnpinChatMessageRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -4644,7 +4786,7 @@ type GenerateChatInviteLinkRequest struct {
ChatId int64 `json:"chat_id"`
}
// Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. In basic groups this can be called only by the group's creator; in supergroups and channels this requires appropriate administrator rights
// Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right
func (client *Client) GenerateChatInviteLink(req *GenerateChatInviteLinkRequest) (*ChatInviteLink, error) {
result, err := client.Send(Request{
meta: meta{
@ -4817,6 +4959,8 @@ type SendCallRatingRequest struct {
Rating int32 `json:"rating"`
// An optional user comment if the rating is less than 5
Comment string `json:"comment"`
// List of the exact types of problems with the call, specified by the user
Problems []CallProblem `json:"problems"`
}
// Sends a call rating
@ -4826,9 +4970,10 @@ func (client *Client) SendCallRating(req *SendCallRatingRequest) (*Ok, error) {
Type: "sendCallRating",
},
Data: map[string]interface{}{
"call_id": req.CallId,
"rating": req.Rating,
"comment": req.Comment,
"call_id": req.CallId,
"rating": req.Rating,
"comment": req.Comment,
"problems": req.Problems,
},
})
if err != nil {
@ -5692,8 +5837,8 @@ type GetStickerEmojisRequest struct {
Sticker InputFile `json:"sticker"`
}
// Returns emoji corresponding to a sticker
func (client *Client) GetStickerEmojis(req *GetStickerEmojisRequest) (*StickerEmojis, error) {
// Returns emoji corresponding to a sticker. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object
func (client *Client) GetStickerEmojis(req *GetStickerEmojisRequest) (*Emojis, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getStickerEmojis",
@ -5710,7 +5855,62 @@ func (client *Client) GetStickerEmojis(req *GetStickerEmojisRequest) (*StickerEm
return nil, buildResponseError(result.Data)
}
return UnmarshalStickerEmojis(result.Data)
return UnmarshalEmojis(result.Data)
}
type SearchEmojisRequest struct {
// Text to search for
Text string `json:"text"`
// True, if only emojis, which exactly match text needs to be returned
ExactMatch bool `json:"exact_match"`
}
// Searches for emojis by keywords. Supported only if the file database is enabled
func (client *Client) SearchEmojis(req *SearchEmojisRequest) (*Emojis, error) {
result, err := client.Send(Request{
meta: meta{
Type: "searchEmojis",
},
Data: map[string]interface{}{
"text": req.Text,
"exact_match": req.ExactMatch,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalEmojis(result.Data)
}
type GetEmojiSuggestionsUrlRequest struct {
// Language code for which the emoji replacements will be suggested
LanguageCode string `json:"language_code"`
}
// Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation
func (client *Client) GetEmojiSuggestionsUrl(req *GetEmojiSuggestionsUrlRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getEmojiSuggestionsUrl",
},
Data: map[string]interface{}{
"language_code": req.LanguageCode,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
// Returns saved animations
@ -6049,10 +6249,8 @@ func (client *Client) SetUsername(req *SetUsernameRequest) (*Ok, error) {
type ChangePhoneNumberRequest struct {
// The new phone number of the user in international format
PhoneNumber string `json:"phone_number"`
// Pass true if the code can be sent via flash call to the specified phone number
AllowFlashCall bool `json:"allow_flash_call"`
// Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
IsCurrentPhoneNumber bool `json:"is_current_phone_number"`
// Settings for the authentication of the user's phone number
Settings *PhoneNumberAuthenticationSettings `json:"settings"`
}
// Changes the phone number of the user and sends an authentication code to the user's new phone number. On success, returns information about the sent code
@ -6062,9 +6260,8 @@ func (client *Client) ChangePhoneNumber(req *ChangePhoneNumberRequest) (*Authent
Type: "changePhoneNumber",
},
Data: map[string]interface{}{
"phone_number": req.PhoneNumber,
"allow_flash_call": req.AllowFlashCall,
"is_current_phone_number": req.IsCurrentPhoneNumber,
"phone_number": req.PhoneNumber,
"settings": req.Settings,
},
})
if err != nil {
@ -6251,35 +6448,6 @@ func (client *Client) DisconnectAllWebsites() (*Ok, error) {
return UnmarshalOk(result.Data)
}
type ToggleBasicGroupAdministratorsRequest struct {
// Identifier of the basic group
BasicGroupId int32 `json:"basic_group_id"`
// New value of everyone_is_administrator
EveryoneIsAdministrator bool `json:"everyone_is_administrator"`
}
// Toggles the "All members are admins" setting in basic groups; requires creator privileges in the group
func (client *Client) ToggleBasicGroupAdministrators(req *ToggleBasicGroupAdministratorsRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "toggleBasicGroupAdministrators",
},
Data: map[string]interface{}{
"basic_group_id": req.BasicGroupId,
"everyone_is_administrator": req.EveryoneIsAdministrator,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type SetSupergroupUsernameRequest struct {
// Identifier of the supergroup or channel
SupergroupId int32 `json:"supergroup_id"`
@ -6316,7 +6484,7 @@ type SetSupergroupStickerSetRequest struct {
StickerSetId JsonInt64 `json:"sticker_set_id"`
}
// Changes the sticker set of a supergroup; requires appropriate rights in the supergroup
// Changes the sticker set of a supergroup; requires can_change_info rights
func (client *Client) SetSupergroupStickerSet(req *SetSupergroupStickerSetRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -6338,35 +6506,6 @@ func (client *Client) SetSupergroupStickerSet(req *SetSupergroupStickerSetReques
return UnmarshalOk(result.Data)
}
type ToggleSupergroupInvitesRequest struct {
// Identifier of the supergroup
SupergroupId int32 `json:"supergroup_id"`
// New value of anyone_can_invite
AnyoneCanInvite bool `json:"anyone_can_invite"`
}
// Toggles whether all members of a supergroup can add new members; requires appropriate administrator rights in the supergroup.
func (client *Client) ToggleSupergroupInvites(req *ToggleSupergroupInvitesRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "toggleSupergroupInvites",
},
Data: map[string]interface{}{
"supergroup_id": req.SupergroupId,
"anyone_can_invite": req.AnyoneCanInvite,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type ToggleSupergroupSignMessagesRequest struct {
// Identifier of the channel
SupergroupId int32 `json:"supergroup_id"`
@ -6374,7 +6513,7 @@ type ToggleSupergroupSignMessagesRequest struct {
SignMessages bool `json:"sign_messages"`
}
// Toggles sender signatures messages sent in a channel; requires appropriate administrator rights in the channel.
// Toggles sender signatures messages sent in a channel; requires can_change_info rights
func (client *Client) ToggleSupergroupSignMessages(req *ToggleSupergroupSignMessagesRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -6403,7 +6542,7 @@ type ToggleSupergroupIsAllHistoryAvailableRequest struct {
IsAllHistoryAvailable bool `json:"is_all_history_available"`
}
// Toggles whether the message history of a supergroup is available to new members; requires appropriate administrator rights in the supergroup.
// Toggles whether the message history of a supergroup is available to new members; requires can_change_info rights
func (client *Client) ToggleSupergroupIsAllHistoryAvailable(req *ToggleSupergroupIsAllHistoryAvailableRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
@ -6425,35 +6564,6 @@ func (client *Client) ToggleSupergroupIsAllHistoryAvailable(req *ToggleSupergrou
return UnmarshalOk(result.Data)
}
type SetSupergroupDescriptionRequest struct {
// Identifier of the supergroup or channel
SupergroupId int32 `json:"supergroup_id"`
// New supergroup or channel description; 0-255 characters
Description string `json:"description"`
}
// Changes information about a supergroup or channel; requires appropriate administrator rights
func (client *Client) SetSupergroupDescription(req *SetSupergroupDescriptionRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setSupergroupDescription",
},
Data: map[string]interface{}{
"supergroup_id": req.SupergroupId,
"description": req.Description,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type ReportSupergroupSpamRequest struct {
// Supergroup identifier
SupergroupId int32 `json:"supergroup_id"`
@ -6821,11 +6931,150 @@ func (client *Client) GetSupportUser() (*User, error) {
return UnmarshalUser(result.Data)
}
// Returns background wallpapers
func (client *Client) GetWallpapers() (*Wallpapers, error) {
type GetBackgroundsRequest struct {
// True, if the backgrounds needs to be ordered for dark theme
ForDarkTheme bool `json:"for_dark_theme"`
}
// Returns backgrounds installed by the user
func (client *Client) GetBackgrounds(req *GetBackgroundsRequest) (*Backgrounds, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getWallpapers",
Type: "getBackgrounds",
},
Data: map[string]interface{}{
"for_dark_theme": req.ForDarkTheme,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalBackgrounds(result.Data)
}
type GetBackgroundUrlRequest struct {
// Background name
Name string `json:"name"`
// Background type
Type BackgroundType `json:"type"`
}
// Constructs a persistent HTTP URL for a background
func (client *Client) GetBackgroundUrl(req *GetBackgroundUrlRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getBackgroundUrl",
},
Data: map[string]interface{}{
"name": req.Name,
"type": req.Type,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalHttpUrl(result.Data)
}
type SearchBackgroundRequest struct {
// The name of the background
Name string `json:"name"`
}
// Searches for a background by its name
func (client *Client) SearchBackground(req *SearchBackgroundRequest) (*Background, error) {
result, err := client.Send(Request{
meta: meta{
Type: "searchBackground",
},
Data: map[string]interface{}{
"name": req.Name,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalBackground(result.Data)
}
type SetBackgroundRequest struct {
// The input background to use, null for solid backgrounds
Background InputBackground `json:"background"`
// Background type; null for default background. The method will return error 404 if type is null
Type BackgroundType `json:"type"`
// True, if the background is chosen for dark theme
ForDarkTheme bool `json:"for_dark_theme"`
}
// Changes the background selected by the user; adds background to the list of installed backgrounds
func (client *Client) SetBackground(req *SetBackgroundRequest) (*Background, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setBackground",
},
Data: map[string]interface{}{
"background": req.Background,
"type": req.Type,
"for_dark_theme": req.ForDarkTheme,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalBackground(result.Data)
}
type RemoveBackgroundRequest struct {
// The background indentifier
BackgroundId JsonInt64 `json:"background_id"`
}
// Removes background from the list of installed backgrounds
func (client *Client) RemoveBackground(req *RemoveBackgroundRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "removeBackground",
},
Data: map[string]interface{}{
"background_id": req.BackgroundId,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
// Resets list of installed backgrounds to its default value
func (client *Client) ResetBackgrounds() (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "resetBackgrounds",
},
Data: map[string]interface{}{},
})
@ -6837,7 +7086,7 @@ func (client *Client) GetWallpapers() (*Wallpapers, error) {
return nil, buildResponseError(result.Data)
}
return UnmarshalWallpapers(result.Data)
return UnmarshalOk(result.Data)
}
type GetLocalizationTargetInfoRequest struct {
@ -7482,7 +7731,7 @@ type GetChatStatisticsUrlRequest struct {
IsDark bool `json:"is_dark"`
}
// Returns URL with the chat statistics. Currently this method can be used only for channels
// Returns an HTTP URL with the chat statistics. Currently this method can be used only for channels
func (client *Client) GetChatStatisticsUrl(req *GetChatStatisticsUrlRequest) (*HttpUrl, error) {
result, err := client.Send(Request{
meta: meta{
@ -7713,6 +7962,54 @@ func (client *Client) ResetNetworkStatistics() (*Ok, error) {
return UnmarshalOk(result.Data)
}
// Returns auto-download settings presets for the currently logged in user
func (client *Client) GetAutoDownloadSettingsPresets() (*AutoDownloadSettingsPresets, error) {
result, err := client.Send(Request{
meta: meta{
Type: "getAutoDownloadSettingsPresets",
},
Data: map[string]interface{}{},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalAutoDownloadSettingsPresets(result.Data)
}
type SetAutoDownloadSettingsRequest struct {
// New user auto-download settings
Settings *AutoDownloadSettings `json:"settings"`
// Type of the network for which the new settings are applied
Type NetworkType `json:"type"`
}
// Sets auto-download settings
func (client *Client) SetAutoDownloadSettings(req *SetAutoDownloadSettingsRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "setAutoDownloadSettings",
},
Data: map[string]interface{}{
"settings": req.Settings,
"type": req.Type,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
type GetPassportElementRequest struct {
// Telegram Passport element type
Type PassportElementType `json:"type"`
@ -7965,10 +8262,8 @@ func (client *Client) GetPreferredCountryLanguage(req *GetPreferredCountryLangua
type SendPhoneNumberVerificationCodeRequest struct {
// The phone number of the user, in international format
PhoneNumber string `json:"phone_number"`
// Pass true if the authentication code may be sent via flash call to the specified phone number
AllowFlashCall bool `json:"allow_flash_call"`
// Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
IsCurrentPhoneNumber bool `json:"is_current_phone_number"`
// Settings for the authentication of the user's phone number
Settings *PhoneNumberAuthenticationSettings `json:"settings"`
}
// Sends a code to verify a phone number to be added to a user's Telegram Passport
@ -7978,9 +8273,8 @@ func (client *Client) SendPhoneNumberVerificationCode(req *SendPhoneNumberVerifi
Type: "sendPhoneNumberVerificationCode",
},
Data: map[string]interface{}{
"phone_number": req.PhoneNumber,
"allow_flash_call": req.AllowFlashCall,
"is_current_phone_number": req.IsCurrentPhoneNumber,
"phone_number": req.PhoneNumber,
"settings": req.Settings,
},
})
if err != nil {
@ -8208,10 +8502,8 @@ type SendPhoneNumberConfirmationCodeRequest struct {
Hash string `json:"hash"`
// Value of the "phone" parameter from the link
PhoneNumber string `json:"phone_number"`
// Pass true if the authentication code may be sent via flash call to the specified phone number
AllowFlashCall bool `json:"allow_flash_call"`
// Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
IsCurrentPhoneNumber bool `json:"is_current_phone_number"`
// Settings for the authentication of the user's phone number
Settings *PhoneNumberAuthenticationSettings `json:"settings"`
}
// Sends phone number confirmation code. Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or "tg://confirmphone?phone=*******&hash=**********" link
@ -8221,10 +8513,9 @@ func (client *Client) SendPhoneNumberConfirmationCode(req *SendPhoneNumberConfir
Type: "sendPhoneNumberConfirmationCode",
},
Data: map[string]interface{}{
"hash": req.Hash,
"phone_number": req.PhoneNumber,
"allow_flash_call": req.AllowFlashCall,
"is_current_phone_number": req.IsCurrentPhoneNumber,
"hash": req.Hash,
"phone_number": req.PhoneNumber,
"settings": req.Settings,
},
})
if err != nil {
@ -8617,7 +8908,7 @@ func (client *Client) SetAlarm(req *SetAlarmRequest) (*Ok, error) {
return UnmarshalOk(result.Data)
}
// Uses current user IP to found his country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization
// Uses current user IP to found their country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization
func (client *Client) GetCountryCode() (*Text, error) {
result, err := client.Send(Request{
meta: meta{
@ -9393,6 +9684,38 @@ func (client *Client) TestNetwork() (*Ok, error) {
return UnmarshalOk(result.Data)
}
type TestProxyRequest struct {
// Proxy server IP address
Server string `json:"server"`
// Proxy server port
Port int32 `json:"port"`
// Proxy type
Type ProxyType `json:"type"`
}
// Sends a simple network request to the Telegram servers via proxy; for testing only. Can be called before authorization
func (client *Client) TestProxy(req *TestProxyRequest) (*Ok, error) {
result, err := client.Send(Request{
meta: meta{
Type: "testProxy",
},
Data: map[string]interface{}{
"server": req.Server,
"port": req.Port,
"type": req.Type,
},
})
if err != nil {
return nil, err
}
if result.Type == "error" {
return nil, buildResponseError(result.Data)
}
return UnmarshalOk(result.Data)
}
// Forces an updates.getDifference call to the Telegram servers; for testing only
func (client *Client) TestGetDifference() (*Ok, error) {
result, err := client.Send(Request{
@ -9468,6 +9791,9 @@ func (client *Client) TestUseUpdate() (Update, error) {
case TypeUpdateChatPhoto:
return UnmarshalUpdateChatPhoto(result.Data)
case TypeUpdateChatPermissions:
return UnmarshalUpdateChatPermissions(result.Data)
case TypeUpdateChatLastMessage:
return UnmarshalUpdateChatLastMessage(result.Data)
@ -9597,6 +9923,9 @@ func (client *Client) TestUseUpdate() (Update, error) {
case TypeUpdateSavedAnimations:
return UnmarshalUpdateSavedAnimations(result.Data)
case TypeUpdateSelectedBackground:
return UnmarshalUpdateSelectedBackground(result.Data)
case TypeUpdateLanguagePackStrings:
return UnmarshalUpdateLanguagePackStrings(result.Data)
@ -9638,13 +9967,20 @@ func (client *Client) TestUseUpdate() (Update, error) {
}
}
// Does nothing and ensures that the Error object is used; for testing only. This is an offline method. Can be called before authorization
func (client *Client) TestUseError() (*Error, error) {
result, err := client.Send(Request{
type TestReturnErrorRequest struct {
// The error to be returned
Error *Error `json:"error"`
}
// Returns the specified error and ensures that the Error object is used; for testing only. This is an offline method. Can be called before authorization. Can be called synchronously
func (client *Client) TestReturnError(req *TestReturnErrorRequest) (*Error, error) {
result, err := client.jsonClient.Execute(Request{
meta: meta{
Type: "testUseError",
Type: "testReturnError",
},
Data: map[string]interface{}{
"error": req.Error,
},
Data: map[string]interface{}{},
})
if err != nil {
return nil, err

View file

@ -3,7 +3,6 @@ package client
/*
#include <stdlib.h>
#include <td/telegram/td_json_client.h>
#include <td/telegram/td_log.h>
*/
import "C"
@ -94,31 +93,6 @@ func (jsonClient *JsonClient) Destroy() {
C.td_json_client_destroy(jsonClient.jsonClient)
}
// Sets the path to the file where the internal TDLib log will be written.
// By default TDLib writes logs to stderr or an OS specific log.
// Use this method to write the log to a file instead.
// Deprecated
func SetLogFilePath(filePath string) {
query := C.CString(filePath)
defer C.free(unsafe.Pointer(query))
C.td_set_log_file_path(query)
}
// Sets maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated.
// Unused if log is not written to a file. Defaults to 10 MB.
// Deprecated
func SetLogMaxFileSize(maxFileSize int64) {
C.td_set_log_max_file_size(C.longlong(maxFileSize))
}
// Sets the verbosity level of the internal logging of TDLib.
// By default the TDLib uses a log verbosity level of 5
// Deprecated
func SetLogVerbosityLevel(newVerbosityLevel int) {
C.td_set_log_verbosity_level(C.int(newVerbosityLevel))
}
type meta struct {
Type string `json:"@type"`
Extra string `json:"@extra"`

File diff suppressed because it is too large Load diff

View file

@ -54,6 +54,9 @@ func UnmarshalAuthorizationState(data json.RawMessage) (AuthorizationState, erro
case TypeAuthorizationStateWaitCode:
return UnmarshalAuthorizationStateWaitCode(data)
case TypeAuthorizationStateWaitRegistration:
return UnmarshalAuthorizationStateWaitRegistration(data)
case TypeAuthorizationStateWaitPassword:
return UnmarshalAuthorizationStateWaitPassword(data)
@ -216,6 +219,9 @@ func UnmarshalChatMembersFilter(data json.RawMessage) (ChatMembersFilter, error)
}
switch meta.Type {
case TypeChatMembersFilterContacts:
return UnmarshalChatMembersFilterContacts(data)
case TypeChatMembersFilterAdministrators:
return UnmarshalChatMembersFilterAdministrators(data)
@ -248,6 +254,9 @@ func UnmarshalSupergroupMembersFilter(data json.RawMessage) (SupergroupMembersFi
case TypeSupergroupMembersFilterRecent:
return UnmarshalSupergroupMembersFilterRecent(data)
case TypeSupergroupMembersFilterContacts:
return UnmarshalSupergroupMembersFilterContacts(data)
case TypeSupergroupMembersFilterAdministrators:
return UnmarshalSupergroupMembersFilterAdministrators(data)
@ -418,6 +427,9 @@ func UnmarshalInlineKeyboardButtonType(data json.RawMessage) (InlineKeyboardButt
case TypeInlineKeyboardButtonTypeUrl:
return UnmarshalInlineKeyboardButtonTypeUrl(data)
case TypeInlineKeyboardButtonTypeLoginUrl:
return UnmarshalInlineKeyboardButtonTypeLoginUrl(data)
case TypeInlineKeyboardButtonTypeCallback:
return UnmarshalInlineKeyboardButtonTypeCallback(data)
@ -1391,6 +1403,41 @@ func UnmarshalCallState(data json.RawMessage) (CallState, error) {
}
}
func UnmarshalCallProblem(data json.RawMessage) (CallProblem, error) {
var meta meta
err := json.Unmarshal(data, &meta)
if err != nil {
return nil, err
}
switch meta.Type {
case TypeCallProblemEcho:
return UnmarshalCallProblemEcho(data)
case TypeCallProblemNoise:
return UnmarshalCallProblemNoise(data)
case TypeCallProblemInterruptions:
return UnmarshalCallProblemInterruptions(data)
case TypeCallProblemDistortedSpeech:
return UnmarshalCallProblemDistortedSpeech(data)
case TypeCallProblemSilentLocal:
return UnmarshalCallProblemSilentLocal(data)
case TypeCallProblemSilentRemote:
return UnmarshalCallProblemSilentRemote(data)
case TypeCallProblemDropped:
return UnmarshalCallProblemDropped(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
}
func UnmarshalInputInlineQueryResult(data json.RawMessage) (InputInlineQueryResult, error) {
var meta meta
@ -1529,6 +1576,9 @@ func UnmarshalChatEventAction(data json.RawMessage) (ChatEventAction, error) {
case TypeChatEventMessageDeleted:
return UnmarshalChatEventMessageDeleted(data)
case TypeChatEventPollStopped:
return UnmarshalChatEventPollStopped(data)
case TypeChatEventMessagePinned:
return UnmarshalChatEventMessagePinned(data)
@ -1553,6 +1603,9 @@ func UnmarshalChatEventAction(data json.RawMessage) (ChatEventAction, error) {
case TypeChatEventTitleChanged:
return UnmarshalChatEventTitleChanged(data)
case TypeChatEventPermissionsChanged:
return UnmarshalChatEventPermissionsChanged(data)
case TypeChatEventDescriptionChanged:
return UnmarshalChatEventDescriptionChanged(data)
@ -1649,6 +1702,49 @@ func UnmarshalDeviceToken(data json.RawMessage) (DeviceToken, error) {
}
}
func UnmarshalBackgroundType(data json.RawMessage) (BackgroundType, error) {
var meta meta
err := json.Unmarshal(data, &meta)
if err != nil {
return nil, err
}
switch meta.Type {
case TypeBackgroundTypeWallpaper:
return UnmarshalBackgroundTypeWallpaper(data)
case TypeBackgroundTypePattern:
return UnmarshalBackgroundTypePattern(data)
case TypeBackgroundTypeSolid:
return UnmarshalBackgroundTypeSolid(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
}
func UnmarshalInputBackground(data json.RawMessage) (InputBackground, error) {
var meta meta
err := json.Unmarshal(data, &meta)
if err != nil {
return nil, err
}
switch meta.Type {
case TypeInputBackgroundLocal:
return UnmarshalInputBackgroundLocal(data)
case TypeInputBackgroundRemote:
return UnmarshalInputBackgroundRemote(data)
default:
return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type)
}
}
func UnmarshalCheckChatUsernameResult(data json.RawMessage) (CheckChatUsernameResult, error) {
var meta meta
@ -1924,6 +2020,12 @@ func UnmarshalUserPrivacySetting(data json.RawMessage) (UserPrivacySetting, erro
case TypeUserPrivacySettingShowStatus:
return UnmarshalUserPrivacySettingShowStatus(data)
case TypeUserPrivacySettingShowProfilePhoto:
return UnmarshalUserPrivacySettingShowProfilePhoto(data)
case TypeUserPrivacySettingShowLinkInForwardedMessages:
return UnmarshalUserPrivacySettingShowLinkInForwardedMessages(data)
case TypeUserPrivacySettingAllowChatInvites:
return UnmarshalUserPrivacySettingAllowChatInvites(data)
@ -2259,6 +2361,9 @@ func UnmarshalUpdate(data json.RawMessage) (Update, error) {
case TypeUpdateChatPhoto:
return UnmarshalUpdateChatPhoto(data)
case TypeUpdateChatPermissions:
return UnmarshalUpdateChatPermissions(data)
case TypeUpdateChatLastMessage:
return UnmarshalUpdateChatLastMessage(data)
@ -2388,6 +2493,9 @@ func UnmarshalUpdate(data json.RawMessage) (Update, error) {
case TypeUpdateSavedAnimations:
return UnmarshalUpdateSavedAnimations(data)
case TypeUpdateSelectedBackground:
return UnmarshalUpdateSelectedBackground(data)
case TypeUpdateLanguagePackStrings:
return UnmarshalUpdateLanguagePackStrings(data)
@ -2588,6 +2696,14 @@ func UnmarshalAuthorizationStateWaitCode(data json.RawMessage) (*AuthorizationSt
return &resp, err
}
func UnmarshalAuthorizationStateWaitRegistration(data json.RawMessage) (*AuthorizationStateWaitRegistration, error) {
var resp AuthorizationStateWaitRegistration
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalAuthorizationStateWaitPassword(data json.RawMessage) (*AuthorizationStateWaitPassword, error) {
var resp AuthorizationStateWaitPassword
@ -2716,6 +2832,14 @@ func UnmarshalPhotoSize(data json.RawMessage) (*PhotoSize, error) {
return &resp, err
}
func UnmarshalMinithumbnail(data json.RawMessage) (*Minithumbnail, error) {
var resp Minithumbnail
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalMaskPointForehead(data json.RawMessage) (*MaskPointForehead, error) {
var resp MaskPointForehead
@ -2996,6 +3120,14 @@ func UnmarshalUsers(data json.RawMessage) (*Users, error) {
return &resp, err
}
func UnmarshalChatPermissions(data json.RawMessage) (*ChatPermissions, error) {
var resp ChatPermissions
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalChatMemberStatusCreator(data json.RawMessage) (*ChatMemberStatusCreator, error) {
var resp ChatMemberStatusCreator
@ -3060,6 +3192,14 @@ func UnmarshalChatMembers(data json.RawMessage) (*ChatMembers, error) {
return &resp, err
}
func UnmarshalChatMembersFilterContacts(data json.RawMessage) (*ChatMembersFilterContacts, error) {
var resp ChatMembersFilterContacts
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalChatMembersFilterAdministrators(data json.RawMessage) (*ChatMembersFilterAdministrators, error) {
var resp ChatMembersFilterAdministrators
@ -3108,6 +3248,14 @@ func UnmarshalSupergroupMembersFilterRecent(data json.RawMessage) (*SupergroupMe
return &resp, err
}
func UnmarshalSupergroupMembersFilterContacts(data json.RawMessage) (*SupergroupMembersFilterContacts, error) {
var resp SupergroupMembersFilterContacts
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalSupergroupMembersFilterAdministrators(data json.RawMessage) (*SupergroupMembersFilterAdministrators, error) {
var resp SupergroupMembersFilterAdministrators
@ -3436,6 +3584,14 @@ func UnmarshalInlineKeyboardButtonTypeUrl(data json.RawMessage) (*InlineKeyboard
return &resp, err
}
func UnmarshalInlineKeyboardButtonTypeLoginUrl(data json.RawMessage) (*InlineKeyboardButtonTypeLoginUrl, error) {
var resp InlineKeyboardButtonTypeLoginUrl
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInlineKeyboardButtonTypeCallback(data json.RawMessage) (*InlineKeyboardButtonTypeCallback, error) {
var resp InlineKeyboardButtonTypeCallback
@ -5508,8 +5664,8 @@ func UnmarshalStickers(data json.RawMessage) (*Stickers, error) {
return &resp, err
}
func UnmarshalStickerEmojis(data json.RawMessage) (*StickerEmojis, error) {
var resp StickerEmojis
func UnmarshalEmojis(data json.RawMessage) (*Emojis, error) {
var resp Emojis
err := json.Unmarshal(data, &resp)
@ -5652,6 +5808,62 @@ func UnmarshalCallStateError(data json.RawMessage) (*CallStateError, error) {
return &resp, err
}
func UnmarshalCallProblemEcho(data json.RawMessage) (*CallProblemEcho, error) {
var resp CallProblemEcho
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemNoise(data json.RawMessage) (*CallProblemNoise, error) {
var resp CallProblemNoise
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemInterruptions(data json.RawMessage) (*CallProblemInterruptions, error) {
var resp CallProblemInterruptions
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemDistortedSpeech(data json.RawMessage) (*CallProblemDistortedSpeech, error) {
var resp CallProblemDistortedSpeech
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemSilentLocal(data json.RawMessage) (*CallProblemSilentLocal, error) {
var resp CallProblemSilentLocal
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemSilentRemote(data json.RawMessage) (*CallProblemSilentRemote, error) {
var resp CallProblemSilentRemote
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCallProblemDropped(data json.RawMessage) (*CallProblemDropped, error) {
var resp CallProblemDropped
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalCall(data json.RawMessage) (*Call, error) {
var resp Call
@ -5660,6 +5872,14 @@ func UnmarshalCall(data json.RawMessage) (*Call, error) {
return &resp, err
}
func UnmarshalPhoneNumberAuthenticationSettings(data json.RawMessage) (*PhoneNumberAuthenticationSettings, error) {
var resp PhoneNumberAuthenticationSettings
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalAnimations(data json.RawMessage) (*Animations, error) {
var resp Animations
@ -5956,6 +6176,14 @@ func UnmarshalChatEventMessageDeleted(data json.RawMessage) (*ChatEventMessageDe
return &resp, err
}
func UnmarshalChatEventPollStopped(data json.RawMessage) (*ChatEventPollStopped, error) {
var resp ChatEventPollStopped
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalChatEventMessagePinned(data json.RawMessage) (*ChatEventMessagePinned, error) {
var resp ChatEventMessagePinned
@ -6020,6 +6248,14 @@ func UnmarshalChatEventTitleChanged(data json.RawMessage) (*ChatEventTitleChange
return &resp, err
}
func UnmarshalChatEventPermissionsChanged(data json.RawMessage) (*ChatEventPermissionsChanged, error) {
var resp ChatEventPermissionsChanged
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalChatEventDescriptionChanged(data json.RawMessage) (*ChatEventDescriptionChanged, error) {
var resp ChatEventDescriptionChanged
@ -6252,16 +6488,56 @@ func UnmarshalPushReceiverId(data json.RawMessage) (*PushReceiverId, error) {
return &resp, err
}
func UnmarshalWallpaper(data json.RawMessage) (*Wallpaper, error) {
var resp Wallpaper
func UnmarshalBackgroundTypeWallpaper(data json.RawMessage) (*BackgroundTypeWallpaper, error) {
var resp BackgroundTypeWallpaper
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalWallpapers(data json.RawMessage) (*Wallpapers, error) {
var resp Wallpapers
func UnmarshalBackgroundTypePattern(data json.RawMessage) (*BackgroundTypePattern, error) {
var resp BackgroundTypePattern
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalBackgroundTypeSolid(data json.RawMessage) (*BackgroundTypeSolid, error) {
var resp BackgroundTypeSolid
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalBackground(data json.RawMessage) (*Background, error) {
var resp Background
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalBackgrounds(data json.RawMessage) (*Backgrounds, error) {
var resp Backgrounds
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInputBackgroundLocal(data json.RawMessage) (*InputBackgroundLocal, error) {
var resp InputBackgroundLocal
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalInputBackgroundRemote(data json.RawMessage) (*InputBackgroundRemote, error) {
var resp InputBackgroundRemote
err := json.Unmarshal(data, &resp)
@ -6756,6 +7032,22 @@ func UnmarshalUserPrivacySettingShowStatus(data json.RawMessage) (*UserPrivacySe
return &resp, err
}
func UnmarshalUserPrivacySettingShowProfilePhoto(data json.RawMessage) (*UserPrivacySettingShowProfilePhoto, error) {
var resp UserPrivacySettingShowProfilePhoto
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalUserPrivacySettingShowLinkInForwardedMessages(data json.RawMessage) (*UserPrivacySettingShowLinkInForwardedMessages, error) {
var resp UserPrivacySettingShowLinkInForwardedMessages
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalUserPrivacySettingAllowChatInvites(data json.RawMessage) (*UserPrivacySettingAllowChatInvites, error) {
var resp UserPrivacySettingAllowChatInvites
@ -6884,6 +7176,14 @@ func UnmarshalPublicMessageLink(data json.RawMessage) (*PublicMessageLink, error
return &resp, err
}
func UnmarshalMessageLinkInfo(data json.RawMessage) (*MessageLinkInfo, error) {
var resp MessageLinkInfo
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalFilePart(data json.RawMessage) (*FilePart, error) {
var resp FilePart
@ -7124,6 +7424,22 @@ func UnmarshalNetworkStatistics(data json.RawMessage) (*NetworkStatistics, error
return &resp, err
}
func UnmarshalAutoDownloadSettings(data json.RawMessage) (*AutoDownloadSettings, error) {
var resp AutoDownloadSettings
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalAutoDownloadSettingsPresets(data json.RawMessage) (*AutoDownloadSettingsPresets, error) {
var resp AutoDownloadSettingsPresets
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalConnectionStateWaitingForNetwork(data json.RawMessage) (*ConnectionStateWaitingForNetwork, error) {
var resp ConnectionStateWaitingForNetwork
@ -7460,6 +7776,14 @@ func UnmarshalUpdateChatPhoto(data json.RawMessage) (*UpdateChatPhoto, error) {
return &resp, err
}
func UnmarshalUpdateChatPermissions(data json.RawMessage) (*UpdateChatPermissions, error) {
var resp UpdateChatPermissions
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalUpdateChatLastMessage(data json.RawMessage) (*UpdateChatLastMessage, error) {
var resp UpdateChatLastMessage
@ -7804,6 +8128,14 @@ func UnmarshalUpdateSavedAnimations(data json.RawMessage) (*UpdateSavedAnimation
return &resp, err
}
func UnmarshalUpdateSelectedBackground(data json.RawMessage) (*UpdateSelectedBackground, error) {
var resp UpdateSelectedBackground
err := json.Unmarshal(data, &resp)
return &resp, err
}
func UnmarshalUpdateLanguagePackStrings(data json.RawMessage) (*UpdateLanguagePackStrings, error) {
var resp UpdateLanguagePackStrings
@ -8064,6 +8396,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeAuthorizationStateWaitCode:
return UnmarshalAuthorizationStateWaitCode(data)
case TypeAuthorizationStateWaitRegistration:
return UnmarshalAuthorizationStateWaitRegistration(data)
case TypeAuthorizationStateWaitPassword:
return UnmarshalAuthorizationStateWaitPassword(data)
@ -8112,6 +8447,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypePhotoSize:
return UnmarshalPhotoSize(data)
case TypeMinithumbnail:
return UnmarshalMinithumbnail(data)
case TypeMaskPointForehead:
return UnmarshalMaskPointForehead(data)
@ -8217,6 +8555,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeUsers:
return UnmarshalUsers(data)
case TypeChatPermissions:
return UnmarshalChatPermissions(data)
case TypeChatMemberStatusCreator:
return UnmarshalChatMemberStatusCreator(data)
@ -8241,6 +8582,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeChatMembers:
return UnmarshalChatMembers(data)
case TypeChatMembersFilterContacts:
return UnmarshalChatMembersFilterContacts(data)
case TypeChatMembersFilterAdministrators:
return UnmarshalChatMembersFilterAdministrators(data)
@ -8259,6 +8603,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeSupergroupMembersFilterRecent:
return UnmarshalSupergroupMembersFilterRecent(data)
case TypeSupergroupMembersFilterContacts:
return UnmarshalSupergroupMembersFilterContacts(data)
case TypeSupergroupMembersFilterAdministrators:
return UnmarshalSupergroupMembersFilterAdministrators(data)
@ -8382,6 +8729,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeInlineKeyboardButtonTypeUrl:
return UnmarshalInlineKeyboardButtonTypeUrl(data)
case TypeInlineKeyboardButtonTypeLoginUrl:
return UnmarshalInlineKeyboardButtonTypeLoginUrl(data)
case TypeInlineKeyboardButtonTypeCallback:
return UnmarshalInlineKeyboardButtonTypeCallback(data)
@ -9159,8 +9509,8 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeStickers:
return UnmarshalStickers(data)
case TypeStickerEmojis:
return UnmarshalStickerEmojis(data)
case TypeEmojis:
return UnmarshalEmojis(data)
case TypeStickerSet:
return UnmarshalStickerSet(data)
@ -9213,9 +9563,33 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeCallStateError:
return UnmarshalCallStateError(data)
case TypeCallProblemEcho:
return UnmarshalCallProblemEcho(data)
case TypeCallProblemNoise:
return UnmarshalCallProblemNoise(data)
case TypeCallProblemInterruptions:
return UnmarshalCallProblemInterruptions(data)
case TypeCallProblemDistortedSpeech:
return UnmarshalCallProblemDistortedSpeech(data)
case TypeCallProblemSilentLocal:
return UnmarshalCallProblemSilentLocal(data)
case TypeCallProblemSilentRemote:
return UnmarshalCallProblemSilentRemote(data)
case TypeCallProblemDropped:
return UnmarshalCallProblemDropped(data)
case TypeCall:
return UnmarshalCall(data)
case TypePhoneNumberAuthenticationSettings:
return UnmarshalPhoneNumberAuthenticationSettings(data)
case TypeAnimations:
return UnmarshalAnimations(data)
@ -9327,6 +9701,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeChatEventMessageDeleted:
return UnmarshalChatEventMessageDeleted(data)
case TypeChatEventPollStopped:
return UnmarshalChatEventPollStopped(data)
case TypeChatEventMessagePinned:
return UnmarshalChatEventMessagePinned(data)
@ -9351,6 +9728,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeChatEventTitleChanged:
return UnmarshalChatEventTitleChanged(data)
case TypeChatEventPermissionsChanged:
return UnmarshalChatEventPermissionsChanged(data)
case TypeChatEventDescriptionChanged:
return UnmarshalChatEventDescriptionChanged(data)
@ -9438,11 +9818,26 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypePushReceiverId:
return UnmarshalPushReceiverId(data)
case TypeWallpaper:
return UnmarshalWallpaper(data)
case TypeBackgroundTypeWallpaper:
return UnmarshalBackgroundTypeWallpaper(data)
case TypeWallpapers:
return UnmarshalWallpapers(data)
case TypeBackgroundTypePattern:
return UnmarshalBackgroundTypePattern(data)
case TypeBackgroundTypeSolid:
return UnmarshalBackgroundTypeSolid(data)
case TypeBackground:
return UnmarshalBackground(data)
case TypeBackgrounds:
return UnmarshalBackgrounds(data)
case TypeInputBackgroundLocal:
return UnmarshalInputBackgroundLocal(data)
case TypeInputBackgroundRemote:
return UnmarshalInputBackgroundRemote(data)
case TypeHashtags:
return UnmarshalHashtags(data)
@ -9627,6 +10022,12 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeUserPrivacySettingShowStatus:
return UnmarshalUserPrivacySettingShowStatus(data)
case TypeUserPrivacySettingShowProfilePhoto:
return UnmarshalUserPrivacySettingShowProfilePhoto(data)
case TypeUserPrivacySettingShowLinkInForwardedMessages:
return UnmarshalUserPrivacySettingShowLinkInForwardedMessages(data)
case TypeUserPrivacySettingAllowChatInvites:
return UnmarshalUserPrivacySettingAllowChatInvites(data)
@ -9675,6 +10076,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypePublicMessageLink:
return UnmarshalPublicMessageLink(data)
case TypeMessageLinkInfo:
return UnmarshalMessageLinkInfo(data)
case TypeFilePart:
return UnmarshalFilePart(data)
@ -9765,6 +10169,12 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeNetworkStatistics:
return UnmarshalNetworkStatistics(data)
case TypeAutoDownloadSettings:
return UnmarshalAutoDownloadSettings(data)
case TypeAutoDownloadSettingsPresets:
return UnmarshalAutoDownloadSettingsPresets(data)
case TypeConnectionStateWaitingForNetwork:
return UnmarshalConnectionStateWaitingForNetwork(data)
@ -9891,6 +10301,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeUpdateChatPhoto:
return UnmarshalUpdateChatPhoto(data)
case TypeUpdateChatPermissions:
return UnmarshalUpdateChatPermissions(data)
case TypeUpdateChatLastMessage:
return UnmarshalUpdateChatLastMessage(data)
@ -10020,6 +10433,9 @@ func UnmarshalType(data json.RawMessage) (Type, error) {
case TypeUpdateSavedAnimations:
return UnmarshalUpdateSavedAnimations(data)
case TypeUpdateSelectedBackground:
return UnmarshalUpdateSelectedBackground(data)
case TypeUpdateLanguagePackStrings:
return UnmarshalUpdateLanguagePackStrings(data)