diff --git a/_schema/layer.tl b/_schema/layer.tl index cec7c282ce..be8f292f29 100644 --- a/_schema/layer.tl +++ b/_schema/layer.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/layer.tl -// Layer: 162 -// SHA256: 2ec2d6c95e8c4cccd15e284391ff502223bfbd733eb6e9f9b20d5ddbb2ea80f7 +// Layer: 163 +// SHA256: 3cfacf26e5eb161e3dc596e56aa39b1b6cdf52cfacc57fec56193edffa3b0731 -// LAYER 162 +// LAYER 163 diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 7da4fba2e7..40fd93854f 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// SHA256: 042e13775257f716afcf769e5e4006bf5c487e3086342a13d3bc72f6fd2a4fde +// SHA256: 3bed831de44aa4ead0770bd7018f05e98be45c76c66432537eda3885a5d64528 boolFalse#bc799737 = Bool; @@ -457,6 +457,8 @@ updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; +updateNewAuthorization#8951abef flags:# unconfirmed:flags.0?true hash:long date:flags.0?int device:flags.0?string location:flags.0?string = Update; + updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; @@ -485,7 +487,7 @@ updateReadHistoryOutbox#2f2f21bf peer:Peer max_id:int pts:int pts_count:int = Up updateWebPage#7f891213 webpage:WebPage pts:int pts_count:int = Update; -updateReadMessagesContents#68c13933 messages:Vector pts:int pts_count:int = Update; +updateReadMessagesContents#f8227181 flags:# messages:Vector pts:int pts_count:int date:flags.0?int = Update; updateChannelTooLong#108d941f flags:# channel_id:long pts:flags.0?int = Update; @@ -929,7 +931,7 @@ webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:fla webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; -authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; +authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true unconfirmed:flags.5?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; @@ -2059,7 +2061,7 @@ attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#d90d8dfe flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true show_in_attach_menu:flags.3?true show_in_side_menu:flags.4?true side_menu_disclaimer_needed:flags.5?true bot_id:long short_name:string peer_types:flags.3?Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; @@ -2225,7 +2227,7 @@ botAppNotModified#5da674b7 = BotApp; botApp#95fcd1d6 flags:# id:long access_hash:long short_name:string title:string description:string photo:Photo document:flags.0?Document hash:long = BotApp; -messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true app:BotApp = messages.BotApp; +messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true has_settings:flags.2?true app:BotApp = messages.BotApp; appWebViewResultUrl#3c1b4f0d url:string = AppWebViewResult; @@ -2502,7 +2504,7 @@ account.getChatThemes#d638de89 hash:long = account.Themes; account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; -account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.changeAuthorizationSettings#40f48462 flags:# confirmed:flags.3?true hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones; @@ -2920,7 +2922,7 @@ messages.requestWebView#269dc2c1 flags:# from_bot_menu:flags.4?true silent:flags messages.prolongWebView#b0d81a83 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#299bec8e flags:# from_switch_webview:flags.1?true bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; +messages.requestSimpleWebView#1a46500a flags:# from_switch_webview:flags.1?true from_side_menu:flags.2?true bot:InputUser url:flags.3?string start_param:flags.4?string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 8c5497d09f..0045b5856e 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Merge: _schema/legacy.tl,_schema/layer.tl -// Layer: 162 -// SHA256: 042e13775257f716afcf769e5e4006bf5c487e3086342a13d3bc72f6fd2a4fde +// Layer: 163 +// SHA256: 3bed831de44aa4ead0770bd7018f05e98be45c76c66432537eda3885a5d64528 boolFalse#bc799737 = Bool; @@ -459,6 +459,8 @@ updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; +updateNewAuthorization#8951abef flags:# unconfirmed:flags.0?true hash:long date:flags.0?int device:flags.0?string location:flags.0?string = Update; + updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; @@ -487,7 +489,7 @@ updateReadHistoryOutbox#2f2f21bf peer:Peer max_id:int pts:int pts_count:int = Up updateWebPage#7f891213 webpage:WebPage pts:int pts_count:int = Update; -updateReadMessagesContents#68c13933 messages:Vector pts:int pts_count:int = Update; +updateReadMessagesContents#f8227181 flags:# messages:Vector pts:int pts_count:int date:flags.0?int = Update; updateChannelTooLong#108d941f flags:# channel_id:long pts:flags.0?int = Update; @@ -931,7 +933,7 @@ webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:fla webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; -authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; +authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true unconfirmed:flags.5?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; @@ -2061,7 +2063,7 @@ attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#d90d8dfe flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true show_in_attach_menu:flags.3?true show_in_side_menu:flags.4?true side_menu_disclaimer_needed:flags.5?true bot_id:long short_name:string peer_types:flags.3?Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; @@ -2227,7 +2229,7 @@ botAppNotModified#5da674b7 = BotApp; botApp#95fcd1d6 flags:# id:long access_hash:long short_name:string title:string description:string photo:Photo document:flags.0?Document hash:long = BotApp; -messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true app:BotApp = messages.BotApp; +messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true has_settings:flags.2?true app:BotApp = messages.BotApp; appWebViewResultUrl#3c1b4f0d url:string = AppWebViewResult; @@ -2504,7 +2506,7 @@ account.getChatThemes#d638de89 hash:long = account.Themes; account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; -account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.changeAuthorizationSettings#40f48462 flags:# confirmed:flags.3?true hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones; @@ -2922,7 +2924,7 @@ messages.requestWebView#269dc2c1 flags:# from_bot_menu:flags.4?true silent:flags messages.prolongWebView#b0d81a83 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#299bec8e flags:# from_switch_webview:flags.1?true bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; +messages.requestSimpleWebView#1a46500a flags:# from_switch_webview:flags.1?true from_side_menu:flags.2?true bot:InputUser url:flags.3?string start_param:flags.4?string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; @@ -3412,4 +3414,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 162 +// LAYER 163 diff --git a/tg/tl_account_change_authorization_settings_gen.go b/tg/tl_account_change_authorization_settings_gen.go index a28e188a35..d975dfbbc5 100644 --- a/tg/tl_account_change_authorization_settings_gen.go +++ b/tg/tl_account_change_authorization_settings_gen.go @@ -41,6 +41,8 @@ type AccountChangeAuthorizationSettingsRequest struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Confirmed field of AccountChangeAuthorizationSettingsRequest. + Confirmed bool // Session ID from the authorization¹ constructor, fetchable using account // getAuthorizations² // @@ -78,6 +80,9 @@ func (c *AccountChangeAuthorizationSettingsRequest) Zero() bool { if !(c.Flags.Zero()) { return false } + if !(c.Confirmed == false) { + return false + } if !(c.Hash == 0) { return false } @@ -102,10 +107,12 @@ func (c *AccountChangeAuthorizationSettingsRequest) String() string { // FillFrom fills AccountChangeAuthorizationSettingsRequest from given interface. func (c *AccountChangeAuthorizationSettingsRequest) FillFrom(from interface { + GetConfirmed() (value bool) GetHash() (value int64) GetEncryptedRequestsDisabled() (value bool, ok bool) GetCallRequestsDisabled() (value bool, ok bool) }) { + c.Confirmed = from.GetConfirmed() c.Hash = from.GetHash() if val, ok := from.GetEncryptedRequestsDisabled(); ok { c.EncryptedRequestsDisabled = val @@ -140,6 +147,11 @@ func (c *AccountChangeAuthorizationSettingsRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Confirmed", + SchemaName: "confirmed", + Null: !c.Flags.Has(3), + }, { Name: "Hash", SchemaName: "hash", @@ -160,6 +172,9 @@ func (c *AccountChangeAuthorizationSettingsRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (c *AccountChangeAuthorizationSettingsRequest) SetFlags() { + if !(c.Confirmed == false) { + c.Flags.Set(3) + } if !(c.EncryptedRequestsDisabled == false) { c.Flags.Set(0) } @@ -217,6 +232,7 @@ func (c *AccountChangeAuthorizationSettingsRequest) DecodeBare(b *bin.Buffer) er return fmt.Errorf("unable to decode account.changeAuthorizationSettings#40f48462: field flags: %w", err) } } + c.Confirmed = c.Flags.Has(3) { value, err := b.Long() if err != nil { @@ -241,6 +257,25 @@ func (c *AccountChangeAuthorizationSettingsRequest) DecodeBare(b *bin.Buffer) er return nil } +// SetConfirmed sets value of Confirmed conditional field. +func (c *AccountChangeAuthorizationSettingsRequest) SetConfirmed(value bool) { + if value { + c.Flags.Set(3) + c.Confirmed = true + } else { + c.Flags.Unset(3) + c.Confirmed = false + } +} + +// GetConfirmed returns value of Confirmed conditional field. +func (c *AccountChangeAuthorizationSettingsRequest) GetConfirmed() (value bool) { + if c == nil { + return + } + return c.Flags.Has(3) +} + // GetHash returns value of Hash field. func (c *AccountChangeAuthorizationSettingsRequest) GetHash() (value int64) { if c == nil { diff --git a/tg/tl_attach_menu_bot_gen.go b/tg/tl_attach_menu_bot_gen.go index 0110f11f8e..a837eab4a5 100644 --- a/tg/tl_attach_menu_bot_gen.go +++ b/tg/tl_attach_menu_bot_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AttachMenuBot represents TL type `attachMenuBot#c8aa2cd2`. +// AttachMenuBot represents TL type `attachMenuBot#d90d8dfe`. // Represents a bot web app that can be launched from the attachment menu »¹ // // Links: @@ -57,11 +57,19 @@ type AttachMenuBot struct { HasSettings bool // Whether the bot would like to send messages to the user. RequestWriteAccess bool + // ShowInAttachMenu field of AttachMenuBot. + ShowInAttachMenu bool + // ShowInSideMenu field of AttachMenuBot. + ShowInSideMenu bool + // SideMenuDisclaimerNeeded field of AttachMenuBot. + SideMenuDisclaimerNeeded bool // Bot ID BotID int64 // Attachment menu item name ShortName string // List of dialog types where this attachment menu entry should be shown + // + // Use SetPeerTypes and GetPeerTypes helpers. PeerTypes []AttachMenuPeerTypeClass // List of platform-specific static icons and animations to use for the attachment menu // button @@ -69,7 +77,7 @@ type AttachMenuBot struct { } // AttachMenuBotTypeID is TL type id of AttachMenuBot. -const AttachMenuBotTypeID = 0xc8aa2cd2 +const AttachMenuBotTypeID = 0xd90d8dfe // Ensuring interfaces in compile-time for AttachMenuBot. var ( @@ -95,6 +103,15 @@ func (a *AttachMenuBot) Zero() bool { if !(a.RequestWriteAccess == false) { return false } + if !(a.ShowInAttachMenu == false) { + return false + } + if !(a.ShowInSideMenu == false) { + return false + } + if !(a.SideMenuDisclaimerNeeded == false) { + return false + } if !(a.BotID == 0) { return false } @@ -125,17 +142,26 @@ func (a *AttachMenuBot) FillFrom(from interface { GetInactive() (value bool) GetHasSettings() (value bool) GetRequestWriteAccess() (value bool) + GetShowInAttachMenu() (value bool) + GetShowInSideMenu() (value bool) + GetSideMenuDisclaimerNeeded() (value bool) GetBotID() (value int64) GetShortName() (value string) - GetPeerTypes() (value []AttachMenuPeerTypeClass) + GetPeerTypes() (value []AttachMenuPeerTypeClass, ok bool) GetIcons() (value []AttachMenuBotIcon) }) { a.Inactive = from.GetInactive() a.HasSettings = from.GetHasSettings() a.RequestWriteAccess = from.GetRequestWriteAccess() + a.ShowInAttachMenu = from.GetShowInAttachMenu() + a.ShowInSideMenu = from.GetShowInSideMenu() + a.SideMenuDisclaimerNeeded = from.GetSideMenuDisclaimerNeeded() a.BotID = from.GetBotID() a.ShortName = from.GetShortName() - a.PeerTypes = from.GetPeerTypes() + if val, ok := from.GetPeerTypes(); ok { + a.PeerTypes = val + } + a.Icons = from.GetIcons() } @@ -177,6 +203,21 @@ func (a *AttachMenuBot) TypeInfo() tdp.Type { SchemaName: "request_write_access", Null: !a.Flags.Has(2), }, + { + Name: "ShowInAttachMenu", + SchemaName: "show_in_attach_menu", + Null: !a.Flags.Has(3), + }, + { + Name: "ShowInSideMenu", + SchemaName: "show_in_side_menu", + Null: !a.Flags.Has(4), + }, + { + Name: "SideMenuDisclaimerNeeded", + SchemaName: "side_menu_disclaimer_needed", + Null: !a.Flags.Has(5), + }, { Name: "BotID", SchemaName: "bot_id", @@ -188,6 +229,7 @@ func (a *AttachMenuBot) TypeInfo() tdp.Type { { Name: "PeerTypes", SchemaName: "peer_types", + Null: !a.Flags.Has(3), }, { Name: "Icons", @@ -208,12 +250,24 @@ func (a *AttachMenuBot) SetFlags() { if !(a.RequestWriteAccess == false) { a.Flags.Set(2) } + if !(a.ShowInAttachMenu == false) { + a.Flags.Set(3) + } + if !(a.ShowInSideMenu == false) { + a.Flags.Set(4) + } + if !(a.SideMenuDisclaimerNeeded == false) { + a.Flags.Set(5) + } + if !(a.PeerTypes == nil) { + a.Flags.Set(3) + } } // Encode implements bin.Encoder. func (a *AttachMenuBot) Encode(b *bin.Buffer) error { if a == nil { - return fmt.Errorf("can't encode attachMenuBot#c8aa2cd2 as nil") + return fmt.Errorf("can't encode attachMenuBot#d90d8dfe as nil") } b.PutID(AttachMenuBotTypeID) return a.EncodeBare(b) @@ -222,27 +276,29 @@ func (a *AttachMenuBot) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (a *AttachMenuBot) EncodeBare(b *bin.Buffer) error { if a == nil { - return fmt.Errorf("can't encode attachMenuBot#c8aa2cd2 as nil") + return fmt.Errorf("can't encode attachMenuBot#d90d8dfe as nil") } a.SetFlags() if err := a.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode attachMenuBot#c8aa2cd2: field flags: %w", err) + return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field flags: %w", err) } b.PutLong(a.BotID) b.PutString(a.ShortName) - b.PutVectorHeader(len(a.PeerTypes)) - for idx, v := range a.PeerTypes { - if v == nil { - return fmt.Errorf("unable to encode attachMenuBot#c8aa2cd2: field peer_types element with index %d is nil", idx) - } - if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode attachMenuBot#c8aa2cd2: field peer_types element with index %d: %w", idx, err) + if a.Flags.Has(3) { + b.PutVectorHeader(len(a.PeerTypes)) + for idx, v := range a.PeerTypes { + if v == nil { + return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field peer_types element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field peer_types element with index %d: %w", idx, err) + } } } b.PutVectorHeader(len(a.Icons)) for idx, v := range a.Icons { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode attachMenuBot#c8aa2cd2: field icons element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field icons element with index %d: %w", idx, err) } } return nil @@ -251,10 +307,10 @@ func (a *AttachMenuBot) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (a *AttachMenuBot) Decode(b *bin.Buffer) error { if a == nil { - return fmt.Errorf("can't decode attachMenuBot#c8aa2cd2 to nil") + return fmt.Errorf("can't decode attachMenuBot#d90d8dfe to nil") } if err := b.ConsumeID(AttachMenuBotTypeID); err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: %w", err) } return a.DecodeBare(b) } @@ -262,34 +318,37 @@ func (a *AttachMenuBot) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { if a == nil { - return fmt.Errorf("can't decode attachMenuBot#c8aa2cd2 to nil") + return fmt.Errorf("can't decode attachMenuBot#d90d8dfe to nil") } { if err := a.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field flags: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field flags: %w", err) } } a.Inactive = a.Flags.Has(0) a.HasSettings = a.Flags.Has(1) a.RequestWriteAccess = a.Flags.Has(2) + a.ShowInAttachMenu = a.Flags.Has(3) + a.ShowInSideMenu = a.Flags.Has(4) + a.SideMenuDisclaimerNeeded = a.Flags.Has(5) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field bot_id: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field bot_id: %w", err) } a.BotID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field short_name: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field short_name: %w", err) } a.ShortName = value } - { + if a.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field peer_types: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field peer_types: %w", err) } if headerLen > 0 { @@ -298,7 +357,7 @@ func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeAttachMenuPeerType(b) if err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field peer_types: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field peer_types: %w", err) } a.PeerTypes = append(a.PeerTypes, value) } @@ -306,7 +365,7 @@ func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field icons: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field icons: %w", err) } if headerLen > 0 { @@ -315,7 +374,7 @@ func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value AttachMenuBotIcon if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode attachMenuBot#c8aa2cd2: field icons: %w", err) + return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field icons: %w", err) } a.Icons = append(a.Icons, value) } @@ -380,6 +439,63 @@ func (a *AttachMenuBot) GetRequestWriteAccess() (value bool) { return a.Flags.Has(2) } +// SetShowInAttachMenu sets value of ShowInAttachMenu conditional field. +func (a *AttachMenuBot) SetShowInAttachMenu(value bool) { + if value { + a.Flags.Set(3) + a.ShowInAttachMenu = true + } else { + a.Flags.Unset(3) + a.ShowInAttachMenu = false + } +} + +// GetShowInAttachMenu returns value of ShowInAttachMenu conditional field. +func (a *AttachMenuBot) GetShowInAttachMenu() (value bool) { + if a == nil { + return + } + return a.Flags.Has(3) +} + +// SetShowInSideMenu sets value of ShowInSideMenu conditional field. +func (a *AttachMenuBot) SetShowInSideMenu(value bool) { + if value { + a.Flags.Set(4) + a.ShowInSideMenu = true + } else { + a.Flags.Unset(4) + a.ShowInSideMenu = false + } +} + +// GetShowInSideMenu returns value of ShowInSideMenu conditional field. +func (a *AttachMenuBot) GetShowInSideMenu() (value bool) { + if a == nil { + return + } + return a.Flags.Has(4) +} + +// SetSideMenuDisclaimerNeeded sets value of SideMenuDisclaimerNeeded conditional field. +func (a *AttachMenuBot) SetSideMenuDisclaimerNeeded(value bool) { + if value { + a.Flags.Set(5) + a.SideMenuDisclaimerNeeded = true + } else { + a.Flags.Unset(5) + a.SideMenuDisclaimerNeeded = false + } +} + +// GetSideMenuDisclaimerNeeded returns value of SideMenuDisclaimerNeeded conditional field. +func (a *AttachMenuBot) GetSideMenuDisclaimerNeeded() (value bool) { + if a == nil { + return + } + return a.Flags.Has(5) +} + // GetBotID returns value of BotID field. func (a *AttachMenuBot) GetBotID() (value int64) { if a == nil { @@ -396,12 +512,22 @@ func (a *AttachMenuBot) GetShortName() (value string) { return a.ShortName } -// GetPeerTypes returns value of PeerTypes field. -func (a *AttachMenuBot) GetPeerTypes() (value []AttachMenuPeerTypeClass) { +// SetPeerTypes sets value of PeerTypes conditional field. +func (a *AttachMenuBot) SetPeerTypes(value []AttachMenuPeerTypeClass) { + a.Flags.Set(3) + a.PeerTypes = value +} + +// GetPeerTypes returns value of PeerTypes conditional field and +// boolean which is true if field was set. +func (a *AttachMenuBot) GetPeerTypes() (value []AttachMenuPeerTypeClass, ok bool) { if a == nil { return } - return a.PeerTypes + if !a.Flags.Has(3) { + return value, false + } + return a.PeerTypes, true } // GetIcons returns value of Icons field. @@ -413,6 +539,9 @@ func (a *AttachMenuBot) GetIcons() (value []AttachMenuBotIcon) { } // MapPeerTypes returns field PeerTypes wrapped in AttachMenuPeerTypeClassArray helper. -func (a *AttachMenuBot) MapPeerTypes() (value AttachMenuPeerTypeClassArray) { - return AttachMenuPeerTypeClassArray(a.PeerTypes) +func (a *AttachMenuBot) MapPeerTypes() (value AttachMenuPeerTypeClassArray, ok bool) { + if !a.Flags.Has(3) { + return value, false + } + return AttachMenuPeerTypeClassArray(a.PeerTypes), true } diff --git a/tg/tl_authorization_gen.go b/tg/tl_authorization_gen.go index 98b25369ab..9c017e962c 100644 --- a/tg/tl_authorization_gen.go +++ b/tg/tl_authorization_gen.go @@ -51,6 +51,8 @@ type Authorization struct { EncryptedRequestsDisabled bool // Whether this session will accept phone calls CallRequestsDisabled bool + // Unconfirmed field of Authorization. + Unconfirmed bool // Identifier Hash int64 // Device model @@ -113,6 +115,9 @@ func (a *Authorization) Zero() bool { if !(a.CallRequestsDisabled == false) { return false } + if !(a.Unconfirmed == false) { + return false + } if !(a.Hash == 0) { return false } @@ -169,6 +174,7 @@ func (a *Authorization) FillFrom(from interface { GetPasswordPending() (value bool) GetEncryptedRequestsDisabled() (value bool) GetCallRequestsDisabled() (value bool) + GetUnconfirmed() (value bool) GetHash() (value int64) GetDeviceModel() (value string) GetPlatform() (value string) @@ -187,6 +193,7 @@ func (a *Authorization) FillFrom(from interface { a.PasswordPending = from.GetPasswordPending() a.EncryptedRequestsDisabled = from.GetEncryptedRequestsDisabled() a.CallRequestsDisabled = from.GetCallRequestsDisabled() + a.Unconfirmed = from.GetUnconfirmed() a.Hash = from.GetHash() a.DeviceModel = from.GetDeviceModel() a.Platform = from.GetPlatform() @@ -249,6 +256,11 @@ func (a *Authorization) TypeInfo() tdp.Type { SchemaName: "call_requests_disabled", Null: !a.Flags.Has(4), }, + { + Name: "Unconfirmed", + SchemaName: "unconfirmed", + Null: !a.Flags.Has(5), + }, { Name: "Hash", SchemaName: "hash", @@ -318,6 +330,9 @@ func (a *Authorization) SetFlags() { if !(a.CallRequestsDisabled == false) { a.Flags.Set(4) } + if !(a.Unconfirmed == false) { + a.Flags.Set(5) + } } // Encode implements bin.Encoder. @@ -379,6 +394,7 @@ func (a *Authorization) DecodeBare(b *bin.Buffer) error { a.PasswordPending = a.Flags.Has(2) a.EncryptedRequestsDisabled = a.Flags.Has(3) a.CallRequestsDisabled = a.Flags.Has(4) + a.Unconfirmed = a.Flags.Has(5) { value, err := b.Long() if err != nil { @@ -561,6 +577,25 @@ func (a *Authorization) GetCallRequestsDisabled() (value bool) { return a.Flags.Has(4) } +// SetUnconfirmed sets value of Unconfirmed conditional field. +func (a *Authorization) SetUnconfirmed(value bool) { + if value { + a.Flags.Set(5) + a.Unconfirmed = true + } else { + a.Flags.Unset(5) + a.Unconfirmed = false + } +} + +// GetUnconfirmed returns value of Unconfirmed conditional field. +func (a *Authorization) GetUnconfirmed() (value bool) { + if a == nil { + return + } + return a.Flags.Has(5) +} + // GetHash returns value of Hash field. func (a *Authorization) GetHash() (value int64) { if a == nil { diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index a4c1b42c69..20f2f80d05 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -186,6 +186,16 @@ func (u UpdateDispatcher) OnUserName(handler UserNameHandler) { } } +// NewAuthorizationHandler is a NewAuthorization event handler. +type NewAuthorizationHandler func(ctx context.Context, e Entities, update *UpdateNewAuthorization) error + +// OnNewAuthorization sets NewAuthorization handler. +func (u UpdateDispatcher) OnNewAuthorization(handler NewAuthorizationHandler) { + u.handlers[UpdateNewAuthorizationTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateNewAuthorization)) + } +} + // NewEncryptedMessageHandler is a NewEncryptedMessage event handler. type NewEncryptedMessageHandler func(ctx context.Context, e Entities, update *UpdateNewEncryptedMessage) error diff --git a/tg/tl_messages_bot_app_gen.go b/tg/tl_messages_bot_app_gen.go index 93cb261f68..036bf4f104 100644 --- a/tg/tl_messages_bot_app_gen.go +++ b/tg/tl_messages_bot_app_gen.go @@ -53,6 +53,8 @@ type MessagesBotApp struct { // Links: // 1) https://core.telegram.org/method/messages.requestAppWebView RequestWriteAccess bool + // HasSettings field of MessagesBotApp. + HasSettings bool // Bot app information App BotAppClass } @@ -81,6 +83,9 @@ func (b *MessagesBotApp) Zero() bool { if !(b.RequestWriteAccess == false) { return false } + if !(b.HasSettings == false) { + return false + } if !(b.App == nil) { return false } @@ -101,10 +106,12 @@ func (b *MessagesBotApp) String() string { func (b *MessagesBotApp) FillFrom(from interface { GetInactive() (value bool) GetRequestWriteAccess() (value bool) + GetHasSettings() (value bool) GetApp() (value BotAppClass) }) { b.Inactive = from.GetInactive() b.RequestWriteAccess = from.GetRequestWriteAccess() + b.HasSettings = from.GetHasSettings() b.App = from.GetApp() } @@ -141,6 +148,11 @@ func (b *MessagesBotApp) TypeInfo() tdp.Type { SchemaName: "request_write_access", Null: !b.Flags.Has(1), }, + { + Name: "HasSettings", + SchemaName: "has_settings", + Null: !b.Flags.Has(2), + }, { Name: "App", SchemaName: "app", @@ -157,6 +169,9 @@ func (b *MessagesBotApp) SetFlags() { if !(b.RequestWriteAccess == false) { b.Flags.Set(1) } + if !(b.HasSettings == false) { + b.Flags.Set(2) + } } // Encode implements bin.Encoder. @@ -209,6 +224,7 @@ func (b *MessagesBotApp) DecodeBare(buf *bin.Buffer) error { } b.Inactive = b.Flags.Has(0) b.RequestWriteAccess = b.Flags.Has(1) + b.HasSettings = b.Flags.Has(2) { value, err := DecodeBotApp(buf) if err != nil { @@ -257,6 +273,25 @@ func (b *MessagesBotApp) GetRequestWriteAccess() (value bool) { return b.Flags.Has(1) } +// SetHasSettings sets value of HasSettings conditional field. +func (b *MessagesBotApp) SetHasSettings(value bool) { + if value { + b.Flags.Set(2) + b.HasSettings = true + } else { + b.Flags.Unset(2) + b.HasSettings = false + } +} + +// GetHasSettings returns value of HasSettings conditional field. +func (b *MessagesBotApp) GetHasSettings() (value bool) { + if b == nil { + return + } + return b.Flags.Has(2) +} + // GetApp returns value of App field. func (b *MessagesBotApp) GetApp() (value BotAppClass) { if b == nil { diff --git a/tg/tl_messages_request_simple_web_view_gen.go b/tg/tl_messages_request_simple_web_view_gen.go index ead8cf231f..9835e12a85 100644 --- a/tg/tl_messages_request_simple_web_view_gen.go +++ b/tg/tl_messages_request_simple_web_view_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesRequestSimpleWebViewRequest represents TL type `messages.requestSimpleWebView#299bec8e`. +// MessagesRequestSimpleWebViewRequest represents TL type `messages.requestSimpleWebView#1a46500a`. // Open a bot web app¹. // // Links: @@ -50,10 +50,18 @@ type MessagesRequestSimpleWebViewRequest struct { // Links: // 1) https://core.telegram.org/method/messages.getInlineBotResults FromSwitchWebview bool + // FromSideMenu field of MessagesRequestSimpleWebViewRequest. + FromSideMenu bool // Bot that owns the webapp Bot InputUserClass // Web app URL + // + // Use SetURL and GetURL helpers. URL string + // StartParam field of MessagesRequestSimpleWebViewRequest. + // + // Use SetStartParam and GetStartParam helpers. + StartParam string // Theme parameters »¹ // // Links: @@ -66,7 +74,7 @@ type MessagesRequestSimpleWebViewRequest struct { } // MessagesRequestSimpleWebViewRequestTypeID is TL type id of MessagesRequestSimpleWebViewRequest. -const MessagesRequestSimpleWebViewRequestTypeID = 0x299bec8e +const MessagesRequestSimpleWebViewRequestTypeID = 0x1a46500a // Ensuring interfaces in compile-time for MessagesRequestSimpleWebViewRequest. var ( @@ -86,12 +94,18 @@ func (r *MessagesRequestSimpleWebViewRequest) Zero() bool { if !(r.FromSwitchWebview == false) { return false } + if !(r.FromSideMenu == false) { + return false + } if !(r.Bot == nil) { return false } if !(r.URL == "") { return false } + if !(r.StartParam == "") { + return false + } if !(r.ThemeParams.Zero()) { return false } @@ -114,14 +128,24 @@ func (r *MessagesRequestSimpleWebViewRequest) String() string { // FillFrom fills MessagesRequestSimpleWebViewRequest from given interface. func (r *MessagesRequestSimpleWebViewRequest) FillFrom(from interface { GetFromSwitchWebview() (value bool) + GetFromSideMenu() (value bool) GetBot() (value InputUserClass) - GetURL() (value string) + GetURL() (value string, ok bool) + GetStartParam() (value string, ok bool) GetThemeParams() (value DataJSON, ok bool) GetPlatform() (value string) }) { r.FromSwitchWebview = from.GetFromSwitchWebview() + r.FromSideMenu = from.GetFromSideMenu() r.Bot = from.GetBot() - r.URL = from.GetURL() + if val, ok := from.GetURL(); ok { + r.URL = val + } + + if val, ok := from.GetStartParam(); ok { + r.StartParam = val + } + if val, ok := from.GetThemeParams(); ok { r.ThemeParams = val } @@ -157,6 +181,11 @@ func (r *MessagesRequestSimpleWebViewRequest) TypeInfo() tdp.Type { SchemaName: "from_switch_webview", Null: !r.Flags.Has(1), }, + { + Name: "FromSideMenu", + SchemaName: "from_side_menu", + Null: !r.Flags.Has(2), + }, { Name: "Bot", SchemaName: "bot", @@ -164,6 +193,12 @@ func (r *MessagesRequestSimpleWebViewRequest) TypeInfo() tdp.Type { { Name: "URL", SchemaName: "url", + Null: !r.Flags.Has(3), + }, + { + Name: "StartParam", + SchemaName: "start_param", + Null: !r.Flags.Has(4), }, { Name: "ThemeParams", @@ -183,6 +218,15 @@ func (r *MessagesRequestSimpleWebViewRequest) SetFlags() { if !(r.FromSwitchWebview == false) { r.Flags.Set(1) } + if !(r.FromSideMenu == false) { + r.Flags.Set(2) + } + if !(r.URL == "") { + r.Flags.Set(3) + } + if !(r.StartParam == "") { + r.Flags.Set(4) + } if !(r.ThemeParams.Zero()) { r.Flags.Set(0) } @@ -191,7 +235,7 @@ func (r *MessagesRequestSimpleWebViewRequest) SetFlags() { // Encode implements bin.Encoder. func (r *MessagesRequestSimpleWebViewRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestSimpleWebView#299bec8e as nil") + return fmt.Errorf("can't encode messages.requestSimpleWebView#1a46500a as nil") } b.PutID(MessagesRequestSimpleWebViewRequestTypeID) return r.EncodeBare(b) @@ -200,22 +244,27 @@ func (r *MessagesRequestSimpleWebViewRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesRequestSimpleWebViewRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestSimpleWebView#299bec8e as nil") + return fmt.Errorf("can't encode messages.requestSimpleWebView#1a46500a as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field flags: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#1a46500a: field flags: %w", err) } if r.Bot == nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field bot is nil") + return fmt.Errorf("unable to encode messages.requestSimpleWebView#1a46500a: field bot is nil") } if err := r.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field bot: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#1a46500a: field bot: %w", err) + } + if r.Flags.Has(3) { + b.PutString(r.URL) + } + if r.Flags.Has(4) { + b.PutString(r.StartParam) } - b.PutString(r.URL) if r.Flags.Has(0) { if err := r.ThemeParams.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestSimpleWebView#299bec8e: field theme_params: %w", err) + return fmt.Errorf("unable to encode messages.requestSimpleWebView#1a46500a: field theme_params: %w", err) } } b.PutString(r.Platform) @@ -225,10 +274,10 @@ func (r *MessagesRequestSimpleWebViewRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesRequestSimpleWebViewRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestSimpleWebView#299bec8e to nil") + return fmt.Errorf("can't decode messages.requestSimpleWebView#1a46500a to nil") } if err := b.ConsumeID(MessagesRequestSimpleWebViewRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: %w", err) } return r.DecodeBare(b) } @@ -236,37 +285,45 @@ func (r *MessagesRequestSimpleWebViewRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesRequestSimpleWebViewRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestSimpleWebView#299bec8e to nil") + return fmt.Errorf("can't decode messages.requestSimpleWebView#1a46500a to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field flags: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field flags: %w", err) } } r.FromSwitchWebview = r.Flags.Has(1) + r.FromSideMenu = r.Flags.Has(2) { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field bot: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field bot: %w", err) } r.Bot = value } - { + if r.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field url: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field url: %w", err) } r.URL = value } + if r.Flags.Has(4) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field start_param: %w", err) + } + r.StartParam = value + } if r.Flags.Has(0) { if err := r.ThemeParams.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field theme_params: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field theme_params: %w", err) } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestSimpleWebView#299bec8e: field platform: %w", err) + return fmt.Errorf("unable to decode messages.requestSimpleWebView#1a46500a: field platform: %w", err) } r.Platform = value } @@ -292,6 +349,25 @@ func (r *MessagesRequestSimpleWebViewRequest) GetFromSwitchWebview() (value bool return r.Flags.Has(1) } +// SetFromSideMenu sets value of FromSideMenu conditional field. +func (r *MessagesRequestSimpleWebViewRequest) SetFromSideMenu(value bool) { + if value { + r.Flags.Set(2) + r.FromSideMenu = true + } else { + r.Flags.Unset(2) + r.FromSideMenu = false + } +} + +// GetFromSideMenu returns value of FromSideMenu conditional field. +func (r *MessagesRequestSimpleWebViewRequest) GetFromSideMenu() (value bool) { + if r == nil { + return + } + return r.Flags.Has(2) +} + // GetBot returns value of Bot field. func (r *MessagesRequestSimpleWebViewRequest) GetBot() (value InputUserClass) { if r == nil { @@ -300,12 +376,40 @@ func (r *MessagesRequestSimpleWebViewRequest) GetBot() (value InputUserClass) { return r.Bot } -// GetURL returns value of URL field. -func (r *MessagesRequestSimpleWebViewRequest) GetURL() (value string) { +// SetURL sets value of URL conditional field. +func (r *MessagesRequestSimpleWebViewRequest) SetURL(value string) { + r.Flags.Set(3) + r.URL = value +} + +// GetURL returns value of URL conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestSimpleWebViewRequest) GetURL() (value string, ok bool) { if r == nil { return } - return r.URL + if !r.Flags.Has(3) { + return value, false + } + return r.URL, true +} + +// SetStartParam sets value of StartParam conditional field. +func (r *MessagesRequestSimpleWebViewRequest) SetStartParam(value string) { + r.Flags.Set(4) + r.StartParam = value +} + +// GetStartParam returns value of StartParam conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestSimpleWebViewRequest) GetStartParam() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(4) { + return value, false + } + return r.StartParam, true } // SetThemeParams sets value of ThemeParams conditional field. @@ -334,7 +438,7 @@ func (r *MessagesRequestSimpleWebViewRequest) GetPlatform() (value string) { return r.Platform } -// MessagesRequestSimpleWebView invokes method messages.requestSimpleWebView#299bec8e returning error if any. +// MessagesRequestSimpleWebView invokes method messages.requestSimpleWebView#1a46500a returning error if any. // Open a bot web app¹. // // Links: diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index da58698d33..a986b9a21a 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 162 +const Layer = 163 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -264,6 +264,7 @@ func TypesMap() map[uint32]string { UpdateChatParticipantsTypeID: "updateChatParticipants#7761198", UpdateUserStatusTypeID: "updateUserStatus#e5bdf8de", UpdateUserNameTypeID: "updateUserName#a7848924", + UpdateNewAuthorizationTypeID: "updateNewAuthorization#8951abef", UpdateNewEncryptedMessageTypeID: "updateNewEncryptedMessage#12bcbd9a", UpdateEncryptedChatTypingTypeID: "updateEncryptedChatTyping#1710f156", UpdateEncryptionTypeID: "updateEncryption#b4a2e88d", @@ -278,7 +279,7 @@ func TypesMap() map[uint32]string { UpdateReadHistoryInboxTypeID: "updateReadHistoryInbox#9c974fdf", UpdateReadHistoryOutboxTypeID: "updateReadHistoryOutbox#2f2f21bf", UpdateWebPageTypeID: "updateWebPage#7f891213", - UpdateReadMessagesContentsTypeID: "updateReadMessagesContents#68c13933", + UpdateReadMessagesContentsTypeID: "updateReadMessagesContents#f8227181", UpdateChannelTooLongTypeID: "updateChannelTooLong#108d941f", UpdateChannelTypeID: "updateChannel#635b4c09", UpdateNewChannelMessageTypeID: "updateNewChannelMessage#62ba04d9", @@ -1065,7 +1066,7 @@ func TypesMap() map[uint32]string { PhoneGroupCallStreamRtmpURLTypeID: "phone.groupCallStreamRtmpUrl#2dbf3432", AttachMenuBotIconColorTypeID: "attachMenuBotIconColor#4576f3f0", AttachMenuBotIconTypeID: "attachMenuBotIcon#b2a7386b", - AttachMenuBotTypeID: "attachMenuBot#c8aa2cd2", + AttachMenuBotTypeID: "attachMenuBot#d90d8dfe", AttachMenuBotsNotModifiedTypeID: "attachMenuBotsNotModified#f1d88a5c", AttachMenuBotsTypeID: "attachMenuBots#3c4301c0", AttachMenuBotsBotTypeID: "attachMenuBotsBot#93bf667f", @@ -1494,7 +1495,7 @@ func TypesMap() map[uint32]string { MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#69f59d69", MessagesRequestWebViewRequestTypeID: "messages.requestWebView#269dc2c1", MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#b0d81a83", - MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#299bec8e", + MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#1a46500a", MessagesSendWebViewResultMessageRequestTypeID: "messages.sendWebViewResultMessage#a4314f5", MessagesSendWebViewDataRequestTypeID: "messages.sendWebViewData#dc0242c8", MessagesTranscribeAudioRequestTypeID: "messages.transcribeAudio#269e9a49", @@ -1969,6 +1970,7 @@ func NamesMap() map[string]uint32 { "updateChatParticipants": UpdateChatParticipantsTypeID, "updateUserStatus": UpdateUserStatusTypeID, "updateUserName": UpdateUserNameTypeID, + "updateNewAuthorization": UpdateNewAuthorizationTypeID, "updateNewEncryptedMessage": UpdateNewEncryptedMessageTypeID, "updateEncryptedChatTyping": UpdateEncryptedChatTypingTypeID, "updateEncryption": UpdateEncryptionTypeID, @@ -3674,6 +3676,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateChatParticipantsTypeID: func() bin.Object { return &UpdateChatParticipants{} }, UpdateUserStatusTypeID: func() bin.Object { return &UpdateUserStatus{} }, UpdateUserNameTypeID: func() bin.Object { return &UpdateUserName{} }, + UpdateNewAuthorizationTypeID: func() bin.Object { return &UpdateNewAuthorization{} }, UpdateNewEncryptedMessageTypeID: func() bin.Object { return &UpdateNewEncryptedMessage{} }, UpdateEncryptedChatTypingTypeID: func() bin.Object { return &UpdateEncryptedChatTyping{} }, UpdateEncryptionTypeID: func() bin.Object { return &UpdateEncryption{} }, @@ -6251,6 +6254,7 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateChatParticipantsTypeID, UpdateUserStatusTypeID, UpdateUserNameTypeID, + UpdateNewAuthorizationTypeID, UpdateNewEncryptedMessageTypeID, UpdateEncryptedChatTypingTypeID, UpdateEncryptionTypeID, diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index 2168c361e7..f52b8bcf56 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -1514,6 +1514,337 @@ func (u *UpdateUserName) GetUsernames() (value []Username) { return u.Usernames } +// UpdateNewAuthorization represents TL type `updateNewAuthorization#8951abef`. +// +// See https://core.telegram.org/constructor/updateNewAuthorization for reference. +type UpdateNewAuthorization struct { + // Flags field of UpdateNewAuthorization. + Flags bin.Fields + // Unconfirmed field of UpdateNewAuthorization. + Unconfirmed bool + // Hash field of UpdateNewAuthorization. + Hash int64 + // Date field of UpdateNewAuthorization. + // + // Use SetDate and GetDate helpers. + Date int + // Device field of UpdateNewAuthorization. + // + // Use SetDevice and GetDevice helpers. + Device string + // Location field of UpdateNewAuthorization. + // + // Use SetLocation and GetLocation helpers. + Location string +} + +// UpdateNewAuthorizationTypeID is TL type id of UpdateNewAuthorization. +const UpdateNewAuthorizationTypeID = 0x8951abef + +// construct implements constructor of UpdateClass. +func (u UpdateNewAuthorization) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateNewAuthorization. +var ( + _ bin.Encoder = &UpdateNewAuthorization{} + _ bin.Decoder = &UpdateNewAuthorization{} + _ bin.BareEncoder = &UpdateNewAuthorization{} + _ bin.BareDecoder = &UpdateNewAuthorization{} + + _ UpdateClass = &UpdateNewAuthorization{} +) + +func (u *UpdateNewAuthorization) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Unconfirmed == false) { + return false + } + if !(u.Hash == 0) { + return false + } + if !(u.Date == 0) { + return false + } + if !(u.Device == "") { + return false + } + if !(u.Location == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateNewAuthorization) String() string { + if u == nil { + return "UpdateNewAuthorization(nil)" + } + type Alias UpdateNewAuthorization + return fmt.Sprintf("UpdateNewAuthorization%+v", Alias(*u)) +} + +// FillFrom fills UpdateNewAuthorization from given interface. +func (u *UpdateNewAuthorization) FillFrom(from interface { + GetUnconfirmed() (value bool) + GetHash() (value int64) + GetDate() (value int, ok bool) + GetDevice() (value string, ok bool) + GetLocation() (value string, ok bool) +}) { + u.Unconfirmed = from.GetUnconfirmed() + u.Hash = from.GetHash() + if val, ok := from.GetDate(); ok { + u.Date = val + } + + if val, ok := from.GetDevice(); ok { + u.Device = val + } + + if val, ok := from.GetLocation(); ok { + u.Location = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateNewAuthorization) TypeID() uint32 { + return UpdateNewAuthorizationTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateNewAuthorization) TypeName() string { + return "updateNewAuthorization" +} + +// TypeInfo returns info about TL type. +func (u *UpdateNewAuthorization) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateNewAuthorization", + ID: UpdateNewAuthorizationTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Unconfirmed", + SchemaName: "unconfirmed", + Null: !u.Flags.Has(0), + }, + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Date", + SchemaName: "date", + Null: !u.Flags.Has(0), + }, + { + Name: "Device", + SchemaName: "device", + Null: !u.Flags.Has(0), + }, + { + Name: "Location", + SchemaName: "location", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdateNewAuthorization) SetFlags() { + if !(u.Unconfirmed == false) { + u.Flags.Set(0) + } + if !(u.Date == 0) { + u.Flags.Set(0) + } + if !(u.Device == "") { + u.Flags.Set(0) + } + if !(u.Location == "") { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *UpdateNewAuthorization) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateNewAuthorization#8951abef as nil") + } + b.PutID(UpdateNewAuthorizationTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateNewAuthorization) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateNewAuthorization#8951abef as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateNewAuthorization#8951abef: field flags: %w", err) + } + b.PutLong(u.Hash) + if u.Flags.Has(0) { + b.PutInt(u.Date) + } + if u.Flags.Has(0) { + b.PutString(u.Device) + } + if u.Flags.Has(0) { + b.PutString(u.Location) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateNewAuthorization) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateNewAuthorization#8951abef to nil") + } + if err := b.ConsumeID(UpdateNewAuthorizationTypeID); err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateNewAuthorization) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateNewAuthorization#8951abef to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: field flags: %w", err) + } + } + u.Unconfirmed = u.Flags.Has(0) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: field hash: %w", err) + } + u.Hash = value + } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: field date: %w", err) + } + u.Date = value + } + if u.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: field device: %w", err) + } + u.Device = value + } + if u.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode updateNewAuthorization#8951abef: field location: %w", err) + } + u.Location = value + } + return nil +} + +// SetUnconfirmed sets value of Unconfirmed conditional field. +func (u *UpdateNewAuthorization) SetUnconfirmed(value bool) { + if value { + u.Flags.Set(0) + u.Unconfirmed = true + } else { + u.Flags.Unset(0) + u.Unconfirmed = false + } +} + +// GetUnconfirmed returns value of Unconfirmed conditional field. +func (u *UpdateNewAuthorization) GetUnconfirmed() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// GetHash returns value of Hash field. +func (u *UpdateNewAuthorization) GetHash() (value int64) { + if u == nil { + return + } + return u.Hash +} + +// SetDate sets value of Date conditional field. +func (u *UpdateNewAuthorization) SetDate(value int) { + u.Flags.Set(0) + u.Date = value +} + +// GetDate returns value of Date conditional field and +// boolean which is true if field was set. +func (u *UpdateNewAuthorization) GetDate() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Date, true +} + +// SetDevice sets value of Device conditional field. +func (u *UpdateNewAuthorization) SetDevice(value string) { + u.Flags.Set(0) + u.Device = value +} + +// GetDevice returns value of Device conditional field and +// boolean which is true if field was set. +func (u *UpdateNewAuthorization) GetDevice() (value string, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Device, true +} + +// SetLocation sets value of Location conditional field. +func (u *UpdateNewAuthorization) SetLocation(value string) { + u.Flags.Set(0) + u.Location = value +} + +// GetLocation returns value of Location conditional field and +// boolean which is true if field was set. +func (u *UpdateNewAuthorization) GetLocation() (value string, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Location, true +} + // UpdateNewEncryptedMessage represents TL type `updateNewEncryptedMessage#12bcbd9a`. // New encrypted message. // @@ -4397,7 +4728,7 @@ func (u *UpdateWebPage) GetPtsCount() (value int) { return u.PtsCount } -// UpdateReadMessagesContents represents TL type `updateReadMessagesContents#68c13933`. +// UpdateReadMessagesContents represents TL type `updateReadMessagesContents#f8227181`. // Contents of messages in the common message box¹ were read // // Links: @@ -4405,6 +4736,8 @@ func (u *UpdateWebPage) GetPtsCount() (value int) { // // See https://core.telegram.org/constructor/updateReadMessagesContents for reference. type UpdateReadMessagesContents struct { + // Flags field of UpdateReadMessagesContents. + Flags bin.Fields // IDs of read messages Messages []int // Event count after generation¹ @@ -4417,10 +4750,14 @@ type UpdateReadMessagesContents struct { // Links: // 1) https://core.telegram.org/api/updates PtsCount int + // Date field of UpdateReadMessagesContents. + // + // Use SetDate and GetDate helpers. + Date int } // UpdateReadMessagesContentsTypeID is TL type id of UpdateReadMessagesContents. -const UpdateReadMessagesContentsTypeID = 0x68c13933 +const UpdateReadMessagesContentsTypeID = 0xf8227181 // construct implements constructor of UpdateClass. func (u UpdateReadMessagesContents) construct() UpdateClass { return &u } @@ -4439,6 +4776,9 @@ func (u *UpdateReadMessagesContents) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } if !(u.Messages == nil) { return false } @@ -4448,6 +4788,9 @@ func (u *UpdateReadMessagesContents) Zero() bool { if !(u.PtsCount == 0) { return false } + if !(u.Date == 0) { + return false + } return true } @@ -4466,10 +4809,15 @@ func (u *UpdateReadMessagesContents) FillFrom(from interface { GetMessages() (value []int) GetPts() (value int) GetPtsCount() (value int) + GetDate() (value int, ok bool) }) { u.Messages = from.GetMessages() u.Pts = from.GetPts() u.PtsCount = from.GetPtsCount() + if val, ok := from.GetDate(); ok { + u.Date = val + } + } // TypeID returns type id in TL schema. @@ -4507,14 +4855,26 @@ func (u *UpdateReadMessagesContents) TypeInfo() tdp.Type { Name: "PtsCount", SchemaName: "pts_count", }, + { + Name: "Date", + SchemaName: "date", + Null: !u.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (u *UpdateReadMessagesContents) SetFlags() { + if !(u.Date == 0) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *UpdateReadMessagesContents) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateReadMessagesContents#68c13933 as nil") + return fmt.Errorf("can't encode updateReadMessagesContents#f8227181 as nil") } b.PutID(UpdateReadMessagesContentsTypeID) return u.EncodeBare(b) @@ -4523,7 +4883,11 @@ func (u *UpdateReadMessagesContents) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateReadMessagesContents) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateReadMessagesContents#68c13933 as nil") + return fmt.Errorf("can't encode updateReadMessagesContents#f8227181 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateReadMessagesContents#f8227181: field flags: %w", err) } b.PutVectorHeader(len(u.Messages)) for _, v := range u.Messages { @@ -4531,16 +4895,19 @@ func (u *UpdateReadMessagesContents) EncodeBare(b *bin.Buffer) error { } b.PutInt(u.Pts) b.PutInt(u.PtsCount) + if u.Flags.Has(0) { + b.PutInt(u.Date) + } return nil } // Decode implements bin.Decoder. func (u *UpdateReadMessagesContents) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateReadMessagesContents#68c13933 to nil") + return fmt.Errorf("can't decode updateReadMessagesContents#f8227181 to nil") } if err := b.ConsumeID(UpdateReadMessagesContentsTypeID); err != nil { - return fmt.Errorf("unable to decode updateReadMessagesContents#68c13933: %w", err) + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: %w", err) } return u.DecodeBare(b) } @@ -4548,12 +4915,17 @@ func (u *UpdateReadMessagesContents) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateReadMessagesContents) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateReadMessagesContents#68c13933 to nil") + return fmt.Errorf("can't decode updateReadMessagesContents#f8227181 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field flags: %w", err) + } } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode updateReadMessagesContents#68c13933: field messages: %w", err) + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field messages: %w", err) } if headerLen > 0 { @@ -4562,7 +4934,7 @@ func (u *UpdateReadMessagesContents) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateReadMessagesContents#68c13933: field messages: %w", err) + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field messages: %w", err) } u.Messages = append(u.Messages, value) } @@ -4570,17 +4942,24 @@ func (u *UpdateReadMessagesContents) DecodeBare(b *bin.Buffer) error { { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateReadMessagesContents#68c13933: field pts: %w", err) + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field pts: %w", err) } u.Pts = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateReadMessagesContents#68c13933: field pts_count: %w", err) + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field pts_count: %w", err) } u.PtsCount = value } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateReadMessagesContents#f8227181: field date: %w", err) + } + u.Date = value + } return nil } @@ -4608,6 +4987,24 @@ func (u *UpdateReadMessagesContents) GetPtsCount() (value int) { return u.PtsCount } +// SetDate sets value of Date conditional field. +func (u *UpdateReadMessagesContents) SetDate(value int) { + u.Flags.Set(0) + u.Date = value +} + +// GetDate returns value of Date conditional field and +// boolean which is true if field was set. +func (u *UpdateReadMessagesContents) GetDate() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Date, true +} + // UpdateChannelTooLong represents TL type `updateChannelTooLong#108d941f`. // There are new updates in the specified channel, the client must fetch them. // If the difference is too long or if the channel isn't currently in the states, start @@ -23060,6 +23457,7 @@ const UpdateClassName = "Update" // case *tg.UpdateChatParticipants: // updateChatParticipants#7761198 // case *tg.UpdateUserStatus: // updateUserStatus#e5bdf8de // case *tg.UpdateUserName: // updateUserName#a7848924 +// case *tg.UpdateNewAuthorization: // updateNewAuthorization#8951abef // case *tg.UpdateNewEncryptedMessage: // updateNewEncryptedMessage#12bcbd9a // case *tg.UpdateEncryptedChatTyping: // updateEncryptedChatTyping#1710f156 // case *tg.UpdateEncryption: // updateEncryption#b4a2e88d @@ -23074,7 +23472,7 @@ const UpdateClassName = "Update" // case *tg.UpdateReadHistoryInbox: // updateReadHistoryInbox#9c974fdf // case *tg.UpdateReadHistoryOutbox: // updateReadHistoryOutbox#2f2f21bf // case *tg.UpdateWebPage: // updateWebPage#7f891213 -// case *tg.UpdateReadMessagesContents: // updateReadMessagesContents#68c13933 +// case *tg.UpdateReadMessagesContents: // updateReadMessagesContents#f8227181 // case *tg.UpdateChannelTooLong: // updateChannelTooLong#108d941f // case *tg.UpdateChannel: // updateChannel#635b4c09 // case *tg.UpdateNewChannelMessage: // updateNewChannelMessage#62ba04d9 @@ -23252,6 +23650,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateNewAuthorizationTypeID: + // Decoding updateNewAuthorization#8951abef. + v := UpdateNewAuthorization{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case UpdateNewEncryptedMessageTypeID: // Decoding updateNewEncryptedMessage#12bcbd9a. v := UpdateNewEncryptedMessage{} @@ -23351,7 +23756,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateReadMessagesContentsTypeID: - // Decoding updateReadMessagesContents#68c13933. + // Decoding updateReadMessagesContents#f8227181. v := UpdateReadMessagesContents{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index 9f395c98bb..88afe7e123 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -220,6 +220,19 @@ func (s UpdateClassArray) AsUpdateUserName() (to UpdateUserNameArray) { return to } +// AsUpdateNewAuthorization returns copy with only UpdateNewAuthorization constructors. +func (s UpdateClassArray) AsUpdateNewAuthorization() (to UpdateNewAuthorizationArray) { + for _, elem := range s { + value, ok := elem.(*UpdateNewAuthorization) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AsUpdateNewEncryptedMessage returns copy with only UpdateNewEncryptedMessage constructors. func (s UpdateClassArray) AsUpdateNewEncryptedMessage() (to UpdateNewEncryptedMessageArray) { for _, elem := range s { @@ -2113,6 +2126,88 @@ func (s *UpdateUserNameArray) Pop() (v UpdateUserName, ok bool) { return v, true } +// UpdateNewAuthorizationArray is adapter for slice of UpdateNewAuthorization. +type UpdateNewAuthorizationArray []UpdateNewAuthorization + +// Sort sorts slice of UpdateNewAuthorization. +func (s UpdateNewAuthorizationArray) Sort(less func(a, b UpdateNewAuthorization) bool) UpdateNewAuthorizationArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateNewAuthorization. +func (s UpdateNewAuthorizationArray) SortStable(less func(a, b UpdateNewAuthorization) bool) UpdateNewAuthorizationArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateNewAuthorization. +func (s UpdateNewAuthorizationArray) Retain(keep func(x UpdateNewAuthorization) bool) UpdateNewAuthorizationArray { + n := 0 + for _, x := range s { + if keep(x) { + s[n] = x + n++ + } + } + s = s[:n] + + return s +} + +// First returns first element of slice (if exists). +func (s UpdateNewAuthorizationArray) First() (v UpdateNewAuthorization, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateNewAuthorizationArray) Last() (v UpdateNewAuthorization, ok bool) { + if len(s) < 1 { + return + } + return s[len(s)-1], true +} + +// PopFirst returns first element of slice (if exists) and deletes it. +func (s *UpdateNewAuthorizationArray) PopFirst() (v UpdateNewAuthorization, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[0] + + // Delete by index from SliceTricks. + copy(a[0:], a[1:]) + var zero UpdateNewAuthorization + a[len(a)-1] = zero + a = a[:len(a)-1] + *s = a + + return v, true +} + +// Pop returns last element of slice (if exists) and deletes it. +func (s *UpdateNewAuthorizationArray) Pop() (v UpdateNewAuthorization, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + // UpdateNewEncryptedMessageArray is adapter for slice of UpdateNewEncryptedMessage. type UpdateNewEncryptedMessageArray []UpdateNewEncryptedMessage