// Code generated by gotdgen, DO NOT EDIT. package tdapi import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/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{} ) // SponsoredChat represents TL type `sponsoredChat#ec953e5f`. type SponsoredChat struct { // Unique identifier of this result UniqueID int64 // Chat identifier ChatID int64 // Additional optional information about the sponsor to be shown along with the chat SponsorInfo string // If non-empty, additional information about the sponsored chat to be shown along with // the chat AdditionalInfo string } // SponsoredChatTypeID is TL type id of SponsoredChat. const SponsoredChatTypeID = 0xec953e5f // Ensuring interfaces in compile-time for SponsoredChat. var ( _ bin.Encoder = &SponsoredChat{} _ bin.Decoder = &SponsoredChat{} _ bin.BareEncoder = &SponsoredChat{} _ bin.BareDecoder = &SponsoredChat{} ) func (s *SponsoredChat) Zero() bool { if s == nil { return true } if !(s.UniqueID == 0) { return false } if !(s.ChatID == 0) { return false } if !(s.SponsorInfo == "") { return false } if !(s.AdditionalInfo == "") { return false } return true } // String implements fmt.Stringer. func (s *SponsoredChat) String() string { if s == nil { return "SponsoredChat(nil)" } type Alias SponsoredChat return fmt.Sprintf("SponsoredChat%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SponsoredChat) TypeID() uint32 { return SponsoredChatTypeID } // TypeName returns name of type in TL schema. func (*SponsoredChat) TypeName() string { return "sponsoredChat" } // TypeInfo returns info about TL type. func (s *SponsoredChat) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "sponsoredChat", ID: SponsoredChatTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "UniqueID", SchemaName: "unique_id", }, { Name: "ChatID", SchemaName: "chat_id", }, { Name: "SponsorInfo", SchemaName: "sponsor_info", }, { Name: "AdditionalInfo", SchemaName: "additional_info", }, } return typ } // Encode implements bin.Encoder. func (s *SponsoredChat) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode sponsoredChat#ec953e5f as nil") } b.PutID(SponsoredChatTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SponsoredChat) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode sponsoredChat#ec953e5f as nil") } b.PutInt53(s.UniqueID) b.PutInt53(s.ChatID) b.PutString(s.SponsorInfo) b.PutString(s.AdditionalInfo) return nil } // Decode implements bin.Decoder. func (s *SponsoredChat) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode sponsoredChat#ec953e5f to nil") } if err := b.ConsumeID(SponsoredChatTypeID); err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SponsoredChat) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode sponsoredChat#ec953e5f to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field unique_id: %w", err) } s.UniqueID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field chat_id: %w", err) } s.ChatID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field sponsor_info: %w", err) } s.SponsorInfo = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field additional_info: %w", err) } s.AdditionalInfo = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SponsoredChat) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode sponsoredChat#ec953e5f as nil") } b.ObjStart() b.PutID("sponsoredChat") b.Comma() b.FieldStart("unique_id") b.PutInt53(s.UniqueID) b.Comma() b.FieldStart("chat_id") b.PutInt53(s.ChatID) b.Comma() b.FieldStart("sponsor_info") b.PutString(s.SponsorInfo) b.Comma() b.FieldStart("additional_info") b.PutString(s.AdditionalInfo) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SponsoredChat) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode sponsoredChat#ec953e5f to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("sponsoredChat"); err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: %w", err) } case "unique_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field unique_id: %w", err) } s.UniqueID = value case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field chat_id: %w", err) } s.ChatID = value case "sponsor_info": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field sponsor_info: %w", err) } s.SponsorInfo = value case "additional_info": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode sponsoredChat#ec953e5f: field additional_info: %w", err) } s.AdditionalInfo = value default: return b.Skip() } return nil }) } // GetUniqueID returns value of UniqueID field. func (s *SponsoredChat) GetUniqueID() (value int64) { if s == nil { return } return s.UniqueID } // GetChatID returns value of ChatID field. func (s *SponsoredChat) GetChatID() (value int64) { if s == nil { return } return s.ChatID } // GetSponsorInfo returns value of SponsorInfo field. func (s *SponsoredChat) GetSponsorInfo() (value string) { if s == nil { return } return s.SponsorInfo } // GetAdditionalInfo returns value of AdditionalInfo field. func (s *SponsoredChat) GetAdditionalInfo() (value string) { if s == nil { return } return s.AdditionalInfo }