diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index b3dd9448cc..9fa76fed91 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// Layer: 178 -// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a +// Layer: 179 +// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4 boolFalse#bc799737 = Bool; @@ -1268,6 +1268,10 @@ auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; +auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType; + +auth.sentCodeTypeSmsPhrase#b37794af flags:# beginning:flags.0?string = auth.SentCodeType; + messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer; messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData; @@ -1836,9 +1840,9 @@ help.userInfoEmpty#f3ae2eed = help.UserInfo; help.userInfo#1eb3758 message:string entities:Vector author:string date:int = help.UserInfo; -pollAnswer#6ca9c2e9 text:string option:bytes = PollAnswer; +pollAnswer#ff16e2ca text:TextWithEntities option:bytes = PollAnswer; -poll#86e18161 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:string answers:Vector close_period:flags.4?int close_date:flags.5?int = Poll; +poll#58747131 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:TextWithEntities answers:Vector close_period:flags.4?int close_date:flags.5?int = Poll; pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true correct:flags.1?true option:bytes voters:int = PollAnswerVoters; @@ -2645,6 +2649,8 @@ auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:str auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode; +auth.reportMissingCode#cb9deff6 phone_number:string phone_code_hash:string mnc:string = Bool; + account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector = Bool; @@ -3833,4 +3839,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 178 +// LAYER 179 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 05d839610b..43281a7bac 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 -// Layer: 178 -// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a +// Layer: 179 +// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4 boolFalse#bc799737 = Bool; @@ -1269,6 +1269,10 @@ auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType; +auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType; + +auth.sentCodeTypeSmsPhrase#b37794af flags:# beginning:flags.0?string = auth.SentCodeType; + messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer; messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData; @@ -1837,9 +1841,9 @@ help.userInfoEmpty#f3ae2eed = help.UserInfo; help.userInfo#1eb3758 message:string entities:Vector author:string date:int = help.UserInfo; -pollAnswer#6ca9c2e9 text:string option:bytes = PollAnswer; +pollAnswer#ff16e2ca text:TextWithEntities option:bytes = PollAnswer; -poll#86e18161 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:string answers:Vector close_period:flags.4?int close_date:flags.5?int = Poll; +poll#58747131 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:TextWithEntities answers:Vector close_period:flags.4?int close_date:flags.5?int = Poll; pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true correct:flags.1?true option:bytes voters:int = PollAnswerVoters; @@ -2646,6 +2650,8 @@ auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:str auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode; +auth.reportMissingCode#cb9deff6 phone_number:string phone_code_hash:string mnc:string = Bool; + account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector = Bool; @@ -3866,4 +3872,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 178 +// LAYER 179 diff --git a/telegram/message/poll.go b/telegram/message/poll.go index aaf8a08cbd..d82d88b74c 100644 --- a/telegram/message/poll.go +++ b/telegram/message/poll.go @@ -28,24 +28,24 @@ func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption { } // PollAnswer creates new plain poll answer option. -func PollAnswer(text string) PollAnswerOption { +func PollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption { return func(p *pollAnswerBuilder) { i := len(p.input.Poll.Answers) p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{ - Text: text, + Text: tg.TextWithEntities{Text: text, Entities: entities}, Option: []byte(strconv.Itoa(i)), }) } } // CorrectPollAnswer creates new correct poll answer option. -func CorrectPollAnswer(text string) PollAnswerOption { +func CorrectPollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption { return func(p *pollAnswerBuilder) { p.input.Poll.Quiz = true i := len(p.input.Poll.Answers) option := []byte(strconv.Itoa(i)) p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{ - Text: text, + Text: tg.TextWithEntities{Text: text, Entities: entities}, Option: option, }) p.input.CorrectAnswers = append(p.input.CorrectAnswers, option) @@ -148,12 +148,19 @@ func (p *PollBuilder) apply(ctx context.Context, b *multiMediaBuilder) error { return Media(&p.input).apply(ctx, b) } +func (p *PollBuilder) QuestionEntities(entities []tg.MessageEntityClass) *PollBuilder { + p.input.Poll.Question.Entities = entities + return p +} + // Poll adds poll attachment. +// +// To set poll question entities, use [QuestionEntities](#PollBuilder.QuestionEntities). func Poll(question string, a, b PollAnswerOption, answers ...PollAnswerOption) *PollBuilder { return &PollBuilder{ input: tg.InputMediaPoll{ Poll: tg.Poll{ - Question: question, + Question: tg.TextWithEntities{Text: question}, }, }, answers: append([]PollAnswerOption{a, b}, answers...), diff --git a/telegram/message/poll_test.go b/telegram/message/poll_test.go index 6e8bbc1440..864f085c84 100644 --- a/telegram/message/poll_test.go +++ b/telegram/message/poll_test.go @@ -43,11 +43,15 @@ func TestPoll(t *testing.T) { CorrectPollAnswer("A?"), PollAnswer("Che?"), PollAnswer("Kuda?"), - ).PublicVoters(true). + ). + PublicVoters(true). StyledExplanation( styling.Plain("See"), styling.TextURL("https://youtu.be/PYzX7SDKhd0.", "https://youtu.be/PYzX7SDKhd0"), - ) + ). + QuestionEntities([]tg.MessageEntityClass{ + &tg.MessageEntityEmail{Offset: 0, Length: 128}, + }) _, err := sender.Self().Media(ctx, poll) require.NoError(t, err) diff --git a/tg/tl_auth_report_missing_code_gen.go b/tg/tl_auth_report_missing_code_gen.go new file mode 100644 index 0000000000..5f8adb3df7 --- /dev/null +++ b/tg/tl_auth_report_missing_code_gen.go @@ -0,0 +1,228 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AuthReportMissingCodeRequest represents TL type `auth.reportMissingCode#cb9deff6`. +// +// See https://core.telegram.org/method/auth.reportMissingCode for reference. +type AuthReportMissingCodeRequest struct { + // PhoneNumber field of AuthReportMissingCodeRequest. + PhoneNumber string + // PhoneCodeHash field of AuthReportMissingCodeRequest. + PhoneCodeHash string + // Mnc field of AuthReportMissingCodeRequest. + Mnc string +} + +// AuthReportMissingCodeRequestTypeID is TL type id of AuthReportMissingCodeRequest. +const AuthReportMissingCodeRequestTypeID = 0xcb9deff6 + +// Ensuring interfaces in compile-time for AuthReportMissingCodeRequest. +var ( + _ bin.Encoder = &AuthReportMissingCodeRequest{} + _ bin.Decoder = &AuthReportMissingCodeRequest{} + _ bin.BareEncoder = &AuthReportMissingCodeRequest{} + _ bin.BareDecoder = &AuthReportMissingCodeRequest{} +) + +func (r *AuthReportMissingCodeRequest) Zero() bool { + if r == nil { + return true + } + if !(r.PhoneNumber == "") { + return false + } + if !(r.PhoneCodeHash == "") { + return false + } + if !(r.Mnc == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *AuthReportMissingCodeRequest) String() string { + if r == nil { + return "AuthReportMissingCodeRequest(nil)" + } + type Alias AuthReportMissingCodeRequest + return fmt.Sprintf("AuthReportMissingCodeRequest%+v", Alias(*r)) +} + +// FillFrom fills AuthReportMissingCodeRequest from given interface. +func (r *AuthReportMissingCodeRequest) FillFrom(from interface { + GetPhoneNumber() (value string) + GetPhoneCodeHash() (value string) + GetMnc() (value string) +}) { + r.PhoneNumber = from.GetPhoneNumber() + r.PhoneCodeHash = from.GetPhoneCodeHash() + r.Mnc = from.GetMnc() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthReportMissingCodeRequest) TypeID() uint32 { + return AuthReportMissingCodeRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthReportMissingCodeRequest) TypeName() string { + return "auth.reportMissingCode" +} + +// TypeInfo returns info about TL type. +func (r *AuthReportMissingCodeRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.reportMissingCode", + ID: AuthReportMissingCodeRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PhoneNumber", + SchemaName: "phone_number", + }, + { + Name: "PhoneCodeHash", + SchemaName: "phone_code_hash", + }, + { + Name: "Mnc", + SchemaName: "mnc", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *AuthReportMissingCodeRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode auth.reportMissingCode#cb9deff6 as nil") + } + b.PutID(AuthReportMissingCodeRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *AuthReportMissingCodeRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode auth.reportMissingCode#cb9deff6 as nil") + } + b.PutString(r.PhoneNumber) + b.PutString(r.PhoneCodeHash) + b.PutString(r.Mnc) + return nil +} + +// Decode implements bin.Decoder. +func (r *AuthReportMissingCodeRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode auth.reportMissingCode#cb9deff6 to nil") + } + if err := b.ConsumeID(AuthReportMissingCodeRequestTypeID); err != nil { + return fmt.Errorf("unable to decode auth.reportMissingCode#cb9deff6: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *AuthReportMissingCodeRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode auth.reportMissingCode#cb9deff6 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.reportMissingCode#cb9deff6: field phone_number: %w", err) + } + r.PhoneNumber = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.reportMissingCode#cb9deff6: field phone_code_hash: %w", err) + } + r.PhoneCodeHash = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.reportMissingCode#cb9deff6: field mnc: %w", err) + } + r.Mnc = value + } + return nil +} + +// GetPhoneNumber returns value of PhoneNumber field. +func (r *AuthReportMissingCodeRequest) GetPhoneNumber() (value string) { + if r == nil { + return + } + return r.PhoneNumber +} + +// GetPhoneCodeHash returns value of PhoneCodeHash field. +func (r *AuthReportMissingCodeRequest) GetPhoneCodeHash() (value string) { + if r == nil { + return + } + return r.PhoneCodeHash +} + +// GetMnc returns value of Mnc field. +func (r *AuthReportMissingCodeRequest) GetMnc() (value string) { + if r == nil { + return + } + return r.Mnc +} + +// AuthReportMissingCode invokes method auth.reportMissingCode#cb9deff6 returning error if any. +// +// See https://core.telegram.org/method/auth.reportMissingCode for reference. +func (c *Client) AuthReportMissingCode(ctx context.Context, request *AuthReportMissingCodeRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_auth_report_missing_code_slices_gen.go b/tg/tl_auth_report_missing_code_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_auth_report_missing_code_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_auth_sent_code_type_gen.go b/tg/tl_auth_sent_code_type_gen.go index d26394c5e6..9790a9b5a3 100644 --- a/tg/tl_auth_sent_code_type_gen.go +++ b/tg/tl_auth_sent_code_type_gen.go @@ -1786,6 +1786,352 @@ func (s *AuthSentCodeTypeFirebaseSMS) GetLength() (value int) { return s.Length } +// AuthSentCodeTypeSMSWord represents TL type `auth.sentCodeTypeSmsWord#a416ac81`. +// +// See https://core.telegram.org/constructor/auth.sentCodeTypeSmsWord for reference. +type AuthSentCodeTypeSMSWord struct { + // Flags field of AuthSentCodeTypeSMSWord. + Flags bin.Fields + // Beginning field of AuthSentCodeTypeSMSWord. + // + // Use SetBeginning and GetBeginning helpers. + Beginning string +} + +// AuthSentCodeTypeSMSWordTypeID is TL type id of AuthSentCodeTypeSMSWord. +const AuthSentCodeTypeSMSWordTypeID = 0xa416ac81 + +// construct implements constructor of AuthSentCodeTypeClass. +func (s AuthSentCodeTypeSMSWord) construct() AuthSentCodeTypeClass { return &s } + +// Ensuring interfaces in compile-time for AuthSentCodeTypeSMSWord. +var ( + _ bin.Encoder = &AuthSentCodeTypeSMSWord{} + _ bin.Decoder = &AuthSentCodeTypeSMSWord{} + _ bin.BareEncoder = &AuthSentCodeTypeSMSWord{} + _ bin.BareDecoder = &AuthSentCodeTypeSMSWord{} + + _ AuthSentCodeTypeClass = &AuthSentCodeTypeSMSWord{} +) + +func (s *AuthSentCodeTypeSMSWord) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Beginning == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AuthSentCodeTypeSMSWord) String() string { + if s == nil { + return "AuthSentCodeTypeSMSWord(nil)" + } + type Alias AuthSentCodeTypeSMSWord + return fmt.Sprintf("AuthSentCodeTypeSMSWord%+v", Alias(*s)) +} + +// FillFrom fills AuthSentCodeTypeSMSWord from given interface. +func (s *AuthSentCodeTypeSMSWord) FillFrom(from interface { + GetBeginning() (value string, ok bool) +}) { + if val, ok := from.GetBeginning(); ok { + s.Beginning = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthSentCodeTypeSMSWord) TypeID() uint32 { + return AuthSentCodeTypeSMSWordTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthSentCodeTypeSMSWord) TypeName() string { + return "auth.sentCodeTypeSmsWord" +} + +// TypeInfo returns info about TL type. +func (s *AuthSentCodeTypeSMSWord) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.sentCodeTypeSmsWord", + ID: AuthSentCodeTypeSMSWordTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Beginning", + SchemaName: "beginning", + Null: !s.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *AuthSentCodeTypeSMSWord) SetFlags() { + if !(s.Beginning == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *AuthSentCodeTypeSMSWord) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSmsWord#a416ac81 as nil") + } + b.PutID(AuthSentCodeTypeSMSWordTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AuthSentCodeTypeSMSWord) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSmsWord#a416ac81 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.sentCodeTypeSmsWord#a416ac81: field flags: %w", err) + } + if s.Flags.Has(0) { + b.PutString(s.Beginning) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AuthSentCodeTypeSMSWord) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSmsWord#a416ac81 to nil") + } + if err := b.ConsumeID(AuthSentCodeTypeSMSWordTypeID); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsWord#a416ac81: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AuthSentCodeTypeSMSWord) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSmsWord#a416ac81 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsWord#a416ac81: field flags: %w", err) + } + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsWord#a416ac81: field beginning: %w", err) + } + s.Beginning = value + } + return nil +} + +// SetBeginning sets value of Beginning conditional field. +func (s *AuthSentCodeTypeSMSWord) SetBeginning(value string) { + s.Flags.Set(0) + s.Beginning = value +} + +// GetBeginning returns value of Beginning conditional field and +// boolean which is true if field was set. +func (s *AuthSentCodeTypeSMSWord) GetBeginning() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.Beginning, true +} + +// AuthSentCodeTypeSMSPhrase represents TL type `auth.sentCodeTypeSmsPhrase#b37794af`. +// +// See https://core.telegram.org/constructor/auth.sentCodeTypeSmsPhrase for reference. +type AuthSentCodeTypeSMSPhrase struct { + // Flags field of AuthSentCodeTypeSMSPhrase. + Flags bin.Fields + // Beginning field of AuthSentCodeTypeSMSPhrase. + // + // Use SetBeginning and GetBeginning helpers. + Beginning string +} + +// AuthSentCodeTypeSMSPhraseTypeID is TL type id of AuthSentCodeTypeSMSPhrase. +const AuthSentCodeTypeSMSPhraseTypeID = 0xb37794af + +// construct implements constructor of AuthSentCodeTypeClass. +func (s AuthSentCodeTypeSMSPhrase) construct() AuthSentCodeTypeClass { return &s } + +// Ensuring interfaces in compile-time for AuthSentCodeTypeSMSPhrase. +var ( + _ bin.Encoder = &AuthSentCodeTypeSMSPhrase{} + _ bin.Decoder = &AuthSentCodeTypeSMSPhrase{} + _ bin.BareEncoder = &AuthSentCodeTypeSMSPhrase{} + _ bin.BareDecoder = &AuthSentCodeTypeSMSPhrase{} + + _ AuthSentCodeTypeClass = &AuthSentCodeTypeSMSPhrase{} +) + +func (s *AuthSentCodeTypeSMSPhrase) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Beginning == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AuthSentCodeTypeSMSPhrase) String() string { + if s == nil { + return "AuthSentCodeTypeSMSPhrase(nil)" + } + type Alias AuthSentCodeTypeSMSPhrase + return fmt.Sprintf("AuthSentCodeTypeSMSPhrase%+v", Alias(*s)) +} + +// FillFrom fills AuthSentCodeTypeSMSPhrase from given interface. +func (s *AuthSentCodeTypeSMSPhrase) FillFrom(from interface { + GetBeginning() (value string, ok bool) +}) { + if val, ok := from.GetBeginning(); ok { + s.Beginning = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthSentCodeTypeSMSPhrase) TypeID() uint32 { + return AuthSentCodeTypeSMSPhraseTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthSentCodeTypeSMSPhrase) TypeName() string { + return "auth.sentCodeTypeSmsPhrase" +} + +// TypeInfo returns info about TL type. +func (s *AuthSentCodeTypeSMSPhrase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.sentCodeTypeSmsPhrase", + ID: AuthSentCodeTypeSMSPhraseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Beginning", + SchemaName: "beginning", + Null: !s.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *AuthSentCodeTypeSMSPhrase) SetFlags() { + if !(s.Beginning == "") { + s.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (s *AuthSentCodeTypeSMSPhrase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSmsPhrase#b37794af as nil") + } + b.PutID(AuthSentCodeTypeSMSPhraseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AuthSentCodeTypeSMSPhrase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode auth.sentCodeTypeSmsPhrase#b37794af as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.sentCodeTypeSmsPhrase#b37794af: field flags: %w", err) + } + if s.Flags.Has(0) { + b.PutString(s.Beginning) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AuthSentCodeTypeSMSPhrase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSmsPhrase#b37794af to nil") + } + if err := b.ConsumeID(AuthSentCodeTypeSMSPhraseTypeID); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsPhrase#b37794af: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AuthSentCodeTypeSMSPhrase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode auth.sentCodeTypeSmsPhrase#b37794af to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsPhrase#b37794af: field flags: %w", err) + } + } + if s.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.sentCodeTypeSmsPhrase#b37794af: field beginning: %w", err) + } + s.Beginning = value + } + return nil +} + +// SetBeginning sets value of Beginning conditional field. +func (s *AuthSentCodeTypeSMSPhrase) SetBeginning(value string) { + s.Flags.Set(0) + s.Beginning = value +} + +// GetBeginning returns value of Beginning conditional field and +// boolean which is true if field was set. +func (s *AuthSentCodeTypeSMSPhrase) GetBeginning() (value string, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.Beginning, true +} + // AuthSentCodeTypeClassName is schema name of AuthSentCodeTypeClass. const AuthSentCodeTypeClassName = "auth.SentCodeType" @@ -1809,6 +2155,8 @@ const AuthSentCodeTypeClassName = "auth.SentCodeType" // case *tg.AuthSentCodeTypeSetUpEmailRequired: // auth.sentCodeTypeSetUpEmailRequired#a5491dea // case *tg.AuthSentCodeTypeFragmentSMS: // auth.sentCodeTypeFragmentSms#d9565c39 // case *tg.AuthSentCodeTypeFirebaseSMS: // auth.sentCodeTypeFirebaseSms#e57b1432 +// case *tg.AuthSentCodeTypeSMSWord: // auth.sentCodeTypeSmsWord#a416ac81 +// case *tg.AuthSentCodeTypeSMSPhrase: // auth.sentCodeTypeSmsPhrase#b37794af // default: panic(v) // } type AuthSentCodeTypeClass interface { @@ -1900,6 +2248,20 @@ func DecodeAuthSentCodeType(buf *bin.Buffer) (AuthSentCodeTypeClass, error) { return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) } return &v, nil + case AuthSentCodeTypeSMSWordTypeID: + // Decoding auth.sentCodeTypeSmsWord#a416ac81. + v := AuthSentCodeTypeSMSWord{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) + } + return &v, nil + case AuthSentCodeTypeSMSPhraseTypeID: + // Decoding auth.sentCodeTypeSmsPhrase#b37794af. + v := AuthSentCodeTypeSMSPhrase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_auth_sent_code_type_slices_gen.go b/tg/tl_auth_sent_code_type_slices_gen.go index 396b13e9f6..0b7320987a 100644 --- a/tg/tl_auth_sent_code_type_slices_gen.go +++ b/tg/tl_auth_sent_code_type_slices_gen.go @@ -233,6 +233,32 @@ func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeFirebaseSMS() (to AuthSent return to } +// AsAuthSentCodeTypeSMSWord returns copy with only AuthSentCodeTypeSMSWord constructors. +func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeSMSWord() (to AuthSentCodeTypeSMSWordArray) { + for _, elem := range s { + value, ok := elem.(*AuthSentCodeTypeSMSWord) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsAuthSentCodeTypeSMSPhrase returns copy with only AuthSentCodeTypeSMSPhrase constructors. +func (s AuthSentCodeTypeClassArray) AsAuthSentCodeTypeSMSPhrase() (to AuthSentCodeTypeSMSPhraseArray) { + for _, elem := range s { + value, ok := elem.(*AuthSentCodeTypeSMSPhrase) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AuthSentCodeTypeAppArray is adapter for slice of AuthSentCodeTypeApp. type AuthSentCodeTypeAppArray []AuthSentCodeTypeApp @@ -970,3 +996,167 @@ func (s *AuthSentCodeTypeFirebaseSMSArray) Pop() (v AuthSentCodeTypeFirebaseSMS, return v, true } + +// AuthSentCodeTypeSMSWordArray is adapter for slice of AuthSentCodeTypeSMSWord. +type AuthSentCodeTypeSMSWordArray []AuthSentCodeTypeSMSWord + +// Sort sorts slice of AuthSentCodeTypeSMSWord. +func (s AuthSentCodeTypeSMSWordArray) Sort(less func(a, b AuthSentCodeTypeSMSWord) bool) AuthSentCodeTypeSMSWordArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AuthSentCodeTypeSMSWord. +func (s AuthSentCodeTypeSMSWordArray) SortStable(less func(a, b AuthSentCodeTypeSMSWord) bool) AuthSentCodeTypeSMSWordArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AuthSentCodeTypeSMSWord. +func (s AuthSentCodeTypeSMSWordArray) Retain(keep func(x AuthSentCodeTypeSMSWord) bool) AuthSentCodeTypeSMSWordArray { + 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 AuthSentCodeTypeSMSWordArray) First() (v AuthSentCodeTypeSMSWord, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AuthSentCodeTypeSMSWordArray) Last() (v AuthSentCodeTypeSMSWord, 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 *AuthSentCodeTypeSMSWordArray) PopFirst() (v AuthSentCodeTypeSMSWord, 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 AuthSentCodeTypeSMSWord + 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 *AuthSentCodeTypeSMSWordArray) Pop() (v AuthSentCodeTypeSMSWord, 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 +} + +// AuthSentCodeTypeSMSPhraseArray is adapter for slice of AuthSentCodeTypeSMSPhrase. +type AuthSentCodeTypeSMSPhraseArray []AuthSentCodeTypeSMSPhrase + +// Sort sorts slice of AuthSentCodeTypeSMSPhrase. +func (s AuthSentCodeTypeSMSPhraseArray) Sort(less func(a, b AuthSentCodeTypeSMSPhrase) bool) AuthSentCodeTypeSMSPhraseArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AuthSentCodeTypeSMSPhrase. +func (s AuthSentCodeTypeSMSPhraseArray) SortStable(less func(a, b AuthSentCodeTypeSMSPhrase) bool) AuthSentCodeTypeSMSPhraseArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AuthSentCodeTypeSMSPhrase. +func (s AuthSentCodeTypeSMSPhraseArray) Retain(keep func(x AuthSentCodeTypeSMSPhrase) bool) AuthSentCodeTypeSMSPhraseArray { + 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 AuthSentCodeTypeSMSPhraseArray) First() (v AuthSentCodeTypeSMSPhrase, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AuthSentCodeTypeSMSPhraseArray) Last() (v AuthSentCodeTypeSMSPhrase, 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 *AuthSentCodeTypeSMSPhraseArray) PopFirst() (v AuthSentCodeTypeSMSPhrase, 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 AuthSentCodeTypeSMSPhrase + 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 *AuthSentCodeTypeSMSPhraseArray) Pop() (v AuthSentCodeTypeSMSPhrase, 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 +} diff --git a/tg/tl_poll_answer_gen.go b/tg/tl_poll_answer_gen.go index fe7db8bd85..d13892fbcd 100644 --- a/tg/tl_poll_answer_gen.go +++ b/tg/tl_poll_answer_gen.go @@ -31,13 +31,13 @@ var ( _ = tdjson.Encoder{} ) -// PollAnswer represents TL type `pollAnswer#6ca9c2e9`. +// PollAnswer represents TL type `pollAnswer#ff16e2ca`. // A possible answer of a poll // // See https://core.telegram.org/constructor/pollAnswer for reference. type PollAnswer struct { // Textual representation of the answer - Text string + Text TextWithEntities // The param that has to be passed to messages.sendVote¹. // // Links: @@ -46,7 +46,7 @@ type PollAnswer struct { } // PollAnswerTypeID is TL type id of PollAnswer. -const PollAnswerTypeID = 0x6ca9c2e9 +const PollAnswerTypeID = 0xff16e2ca // Ensuring interfaces in compile-time for PollAnswer. var ( @@ -60,7 +60,7 @@ func (p *PollAnswer) Zero() bool { if p == nil { return true } - if !(p.Text == "") { + if !(p.Text.Zero()) { return false } if !(p.Option == nil) { @@ -81,7 +81,7 @@ func (p *PollAnswer) String() string { // FillFrom fills PollAnswer from given interface. func (p *PollAnswer) FillFrom(from interface { - GetText() (value string) + GetText() (value TextWithEntities) GetOption() (value []byte) }) { p.Text = from.GetText() @@ -126,7 +126,7 @@ func (p *PollAnswer) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (p *PollAnswer) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode pollAnswer#6ca9c2e9 as nil") + return fmt.Errorf("can't encode pollAnswer#ff16e2ca as nil") } b.PutID(PollAnswerTypeID) return p.EncodeBare(b) @@ -135,9 +135,11 @@ func (p *PollAnswer) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *PollAnswer) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode pollAnswer#6ca9c2e9 as nil") + return fmt.Errorf("can't encode pollAnswer#ff16e2ca as nil") + } + if err := p.Text.Encode(b); err != nil { + return fmt.Errorf("unable to encode pollAnswer#ff16e2ca: field text: %w", err) } - b.PutString(p.Text) b.PutBytes(p.Option) return nil } @@ -145,10 +147,10 @@ func (p *PollAnswer) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *PollAnswer) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode pollAnswer#6ca9c2e9 to nil") + return fmt.Errorf("can't decode pollAnswer#ff16e2ca to nil") } if err := b.ConsumeID(PollAnswerTypeID); err != nil { - return fmt.Errorf("unable to decode pollAnswer#6ca9c2e9: %w", err) + return fmt.Errorf("unable to decode pollAnswer#ff16e2ca: %w", err) } return p.DecodeBare(b) } @@ -156,19 +158,17 @@ func (p *PollAnswer) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *PollAnswer) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode pollAnswer#6ca9c2e9 to nil") + return fmt.Errorf("can't decode pollAnswer#ff16e2ca to nil") } { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode pollAnswer#6ca9c2e9: field text: %w", err) + if err := p.Text.Decode(b); err != nil { + return fmt.Errorf("unable to decode pollAnswer#ff16e2ca: field text: %w", err) } - p.Text = value } { value, err := b.Bytes() if err != nil { - return fmt.Errorf("unable to decode pollAnswer#6ca9c2e9: field option: %w", err) + return fmt.Errorf("unable to decode pollAnswer#ff16e2ca: field option: %w", err) } p.Option = value } @@ -176,7 +176,7 @@ func (p *PollAnswer) DecodeBare(b *bin.Buffer) error { } // GetText returns value of Text field. -func (p *PollAnswer) GetText() (value string) { +func (p *PollAnswer) GetText() (value TextWithEntities) { if p == nil { return } diff --git a/tg/tl_poll_gen.go b/tg/tl_poll_gen.go index 0cf20f074a..dd90dd0432 100644 --- a/tg/tl_poll_gen.go +++ b/tg/tl_poll_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// Poll represents TL type `poll#86e18161`. +// Poll represents TL type `poll#58747131`. // Poll // // See https://core.telegram.org/constructor/poll for reference. @@ -53,7 +53,7 @@ type Poll struct { // type) Quiz bool // The question of the poll - Question string + Question TextWithEntities // The possible answers, vote using messages.sendVote¹. // // Links: @@ -73,7 +73,7 @@ type Poll struct { } // PollTypeID is TL type id of Poll. -const PollTypeID = 0x86e18161 +const PollTypeID = 0x58747131 // Ensuring interfaces in compile-time for Poll. var ( @@ -105,7 +105,7 @@ func (p *Poll) Zero() bool { if !(p.Quiz == false) { return false } - if !(p.Question == "") { + if !(p.Question.Zero()) { return false } if !(p.Answers == nil) { @@ -137,7 +137,7 @@ func (p *Poll) FillFrom(from interface { GetPublicVoters() (value bool) GetMultipleChoice() (value bool) GetQuiz() (value bool) - GetQuestion() (value string) + GetQuestion() (value TextWithEntities) GetAnswers() (value []PollAnswer) GetClosePeriod() (value int, ok bool) GetCloseDate() (value int, ok bool) @@ -253,7 +253,7 @@ func (p *Poll) SetFlags() { // Encode implements bin.Encoder. func (p *Poll) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode poll#86e18161 as nil") + return fmt.Errorf("can't encode poll#58747131 as nil") } b.PutID(PollTypeID) return p.EncodeBare(b) @@ -262,18 +262,20 @@ func (p *Poll) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *Poll) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode poll#86e18161 as nil") + return fmt.Errorf("can't encode poll#58747131 as nil") } p.SetFlags() b.PutLong(p.ID) if err := p.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode poll#86e18161: field flags: %w", err) + return fmt.Errorf("unable to encode poll#58747131: field flags: %w", err) + } + if err := p.Question.Encode(b); err != nil { + return fmt.Errorf("unable to encode poll#58747131: field question: %w", err) } - b.PutString(p.Question) b.PutVectorHeader(len(p.Answers)) for idx, v := range p.Answers { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode poll#86e18161: field answers element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode poll#58747131: field answers element with index %d: %w", idx, err) } } if p.Flags.Has(4) { @@ -288,10 +290,10 @@ func (p *Poll) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *Poll) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode poll#86e18161 to nil") + return fmt.Errorf("can't decode poll#58747131 to nil") } if err := b.ConsumeID(PollTypeID); err != nil { - return fmt.Errorf("unable to decode poll#86e18161: %w", err) + return fmt.Errorf("unable to decode poll#58747131: %w", err) } return p.DecodeBare(b) } @@ -299,18 +301,18 @@ func (p *Poll) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *Poll) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode poll#86e18161 to nil") + return fmt.Errorf("can't decode poll#58747131 to nil") } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field id: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field id: %w", err) } p.ID = value } { if err := p.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field flags: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field flags: %w", err) } } p.Closed = p.Flags.Has(0) @@ -318,16 +320,14 @@ func (p *Poll) DecodeBare(b *bin.Buffer) error { p.MultipleChoice = p.Flags.Has(2) p.Quiz = p.Flags.Has(3) { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field question: %w", err) + if err := p.Question.Decode(b); err != nil { + return fmt.Errorf("unable to decode poll#58747131: field question: %w", err) } - p.Question = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field answers: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field answers: %w", err) } if headerLen > 0 { @@ -336,7 +336,7 @@ func (p *Poll) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value PollAnswer if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field answers: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field answers: %w", err) } p.Answers = append(p.Answers, value) } @@ -344,14 +344,14 @@ func (p *Poll) DecodeBare(b *bin.Buffer) error { if p.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field close_period: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field close_period: %w", err) } p.ClosePeriod = value } if p.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode poll#86e18161: field close_date: %w", err) + return fmt.Errorf("unable to decode poll#58747131: field close_date: %w", err) } p.CloseDate = value } @@ -443,7 +443,7 @@ func (p *Poll) GetQuiz() (value bool) { } // GetQuestion returns value of Question field. -func (p *Poll) GetQuestion() (value string) { +func (p *Poll) GetQuestion() (value TextWithEntities) { if p == nil { return } diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index d178db6fed..a058ae84bf 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 178 +const Layer = 179 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -669,6 +669,8 @@ func TypesMap() map[uint32]string { AuthSentCodeTypeSetUpEmailRequiredTypeID: "auth.sentCodeTypeSetUpEmailRequired#a5491dea", AuthSentCodeTypeFragmentSMSTypeID: "auth.sentCodeTypeFragmentSms#d9565c39", AuthSentCodeTypeFirebaseSMSTypeID: "auth.sentCodeTypeFirebaseSms#e57b1432", + AuthSentCodeTypeSMSWordTypeID: "auth.sentCodeTypeSmsWord#a416ac81", + AuthSentCodeTypeSMSPhraseTypeID: "auth.sentCodeTypeSmsPhrase#b37794af", MessagesBotCallbackAnswerTypeID: "messages.botCallbackAnswer#36585ea4", MessagesMessageEditDataTypeID: "messages.messageEditData#26b5dde6", InputBotInlineMessageIDTypeID: "inputBotInlineMessageID#890c3d89", @@ -953,8 +955,8 @@ func TypesMap() map[uint32]string { HelpSupportNameTypeID: "help.supportName#8c05f1c9", HelpUserInfoEmptyTypeID: "help.userInfoEmpty#f3ae2eed", HelpUserInfoTypeID: "help.userInfo#1eb3758", - PollAnswerTypeID: "pollAnswer#6ca9c2e9", - PollTypeID: "poll#86e18161", + PollAnswerTypeID: "pollAnswer#ff16e2ca", + PollTypeID: "poll#58747131", PollAnswerVotersTypeID: "pollAnswerVoters#3b6ddad2", PollResultsTypeID: "pollResults#7adf2420", ChatOnlinesTypeID: "chatOnlines#f041e250", @@ -1356,6 +1358,7 @@ func TypesMap() map[uint32]string { AuthImportWebTokenAuthorizationRequestTypeID: "auth.importWebTokenAuthorization#2db873a9", AuthRequestFirebaseSMSRequestTypeID: "auth.requestFirebaseSms#89464b50", AuthResetLoginEmailRequestTypeID: "auth.resetLoginEmail#7e960193", + AuthReportMissingCodeRequestTypeID: "auth.reportMissingCode#cb9deff6", AccountRegisterDeviceRequestTypeID: "account.registerDevice#ec86017a", AccountUnregisterDeviceRequestTypeID: "account.unregisterDevice#6a0d3206", AccountUpdateNotifySettingsRequestTypeID: "account.updateNotifySettings#84be5b93", @@ -2601,6 +2604,8 @@ func NamesMap() map[string]uint32 { "auth.sentCodeTypeSetUpEmailRequired": AuthSentCodeTypeSetUpEmailRequiredTypeID, "auth.sentCodeTypeFragmentSms": AuthSentCodeTypeFragmentSMSTypeID, "auth.sentCodeTypeFirebaseSms": AuthSentCodeTypeFirebaseSMSTypeID, + "auth.sentCodeTypeSmsWord": AuthSentCodeTypeSMSWordTypeID, + "auth.sentCodeTypeSmsPhrase": AuthSentCodeTypeSMSPhraseTypeID, "messages.botCallbackAnswer": MessagesBotCallbackAnswerTypeID, "messages.messageEditData": MessagesMessageEditDataTypeID, "inputBotInlineMessageID": InputBotInlineMessageIDTypeID, @@ -3288,6 +3293,7 @@ func NamesMap() map[string]uint32 { "auth.importWebTokenAuthorization": AuthImportWebTokenAuthorizationRequestTypeID, "auth.requestFirebaseSms": AuthRequestFirebaseSMSRequestTypeID, "auth.resetLoginEmail": AuthResetLoginEmailRequestTypeID, + "auth.reportMissingCode": AuthReportMissingCodeRequestTypeID, "account.registerDevice": AccountRegisterDeviceRequestTypeID, "account.unregisterDevice": AccountUnregisterDeviceRequestTypeID, "account.updateNotifySettings": AccountUpdateNotifySettingsRequestTypeID, @@ -4533,6 +4539,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AuthSentCodeTypeSetUpEmailRequiredTypeID: func() bin.Object { return &AuthSentCodeTypeSetUpEmailRequired{} }, AuthSentCodeTypeFragmentSMSTypeID: func() bin.Object { return &AuthSentCodeTypeFragmentSMS{} }, AuthSentCodeTypeFirebaseSMSTypeID: func() bin.Object { return &AuthSentCodeTypeFirebaseSMS{} }, + AuthSentCodeTypeSMSWordTypeID: func() bin.Object { return &AuthSentCodeTypeSMSWord{} }, + AuthSentCodeTypeSMSPhraseTypeID: func() bin.Object { return &AuthSentCodeTypeSMSPhrase{} }, MessagesBotCallbackAnswerTypeID: func() bin.Object { return &MessagesBotCallbackAnswer{} }, MessagesMessageEditDataTypeID: func() bin.Object { return &MessagesMessageEditData{} }, InputBotInlineMessageIDTypeID: func() bin.Object { return &InputBotInlineMessageID{} }, @@ -5220,6 +5228,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AuthImportWebTokenAuthorizationRequestTypeID: func() bin.Object { return &AuthImportWebTokenAuthorizationRequest{} }, AuthRequestFirebaseSMSRequestTypeID: func() bin.Object { return &AuthRequestFirebaseSMSRequest{} }, AuthResetLoginEmailRequestTypeID: func() bin.Object { return &AuthResetLoginEmailRequest{} }, + AuthReportMissingCodeRequestTypeID: func() bin.Object { return &AuthReportMissingCodeRequest{} }, AccountRegisterDeviceRequestTypeID: func() bin.Object { return &AccountRegisterDeviceRequest{} }, AccountUnregisterDeviceRequestTypeID: func() bin.Object { return &AccountUnregisterDeviceRequest{} }, AccountUpdateNotifySettingsRequestTypeID: func() bin.Object { return &AccountUpdateNotifySettingsRequest{} }, @@ -5903,6 +5912,8 @@ func ClassConstructorsMap() map[string][]uint32 { AuthSentCodeTypeSetUpEmailRequiredTypeID, AuthSentCodeTypeFragmentSMSTypeID, AuthSentCodeTypeFirebaseSMSTypeID, + AuthSentCodeTypeSMSWordTypeID, + AuthSentCodeTypeSMSPhraseTypeID, }, BaseThemeClassName: { BaseThemeClassicTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 107d3a3665..ddb126395b 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -455,6 +455,27 @@ func (s *ServerDispatcher) OnAuthResetLoginEmail(f func(ctx context.Context, req s.handlers[AuthResetLoginEmailRequestTypeID] = handler } +func (s *ServerDispatcher) OnAuthReportMissingCode(f func(ctx context.Context, request *AuthReportMissingCodeRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AuthReportMissingCodeRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[AuthReportMissingCodeRequestTypeID] = handler +} + func (s *ServerDispatcher) OnAccountRegisterDevice(f func(ctx context.Context, request *AccountRegisterDeviceRequest) (bool, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request AccountRegisterDeviceRequest