// Code generated by gotdgen, DO NOT EDIT. package tg 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{} ) // BotVerification represents TL type `botVerification#f93cd45c`. // Describes a bot verification icon »¹. // // Links: // 1. https://core.telegram.org/api/bots/verification // // See https://core.telegram.org/constructor/botVerification for reference. type BotVerification struct { // ID of the bot that verified this peer BotID int64 // Verification icon Icon int64 // Verification description Description string } // BotVerificationTypeID is TL type id of BotVerification. const BotVerificationTypeID = 0xf93cd45c // Ensuring interfaces in compile-time for BotVerification. var ( _ bin.Encoder = &BotVerification{} _ bin.Decoder = &BotVerification{} _ bin.BareEncoder = &BotVerification{} _ bin.BareDecoder = &BotVerification{} ) func (b *BotVerification) Zero() bool { if b == nil { return true } if !(b.BotID == 0) { return false } if !(b.Icon == 0) { return false } if !(b.Description == "") { return false } return true } // String implements fmt.Stringer. func (b *BotVerification) String() string { if b == nil { return "BotVerification(nil)" } type Alias BotVerification return fmt.Sprintf("BotVerification%+v", Alias(*b)) } // FillFrom fills BotVerification from given interface. func (b *BotVerification) FillFrom(from interface { GetBotID() (value int64) GetIcon() (value int64) GetDescription() (value string) }) { b.BotID = from.GetBotID() b.Icon = from.GetIcon() b.Description = from.GetDescription() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BotVerification) TypeID() uint32 { return BotVerificationTypeID } // TypeName returns name of type in TL schema. func (*BotVerification) TypeName() string { return "botVerification" } // TypeInfo returns info about TL type. func (b *BotVerification) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "botVerification", ID: BotVerificationTypeID, } if b == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "BotID", SchemaName: "bot_id", }, { Name: "Icon", SchemaName: "icon", }, { Name: "Description", SchemaName: "description", }, } return typ } // Encode implements bin.Encoder. func (b *BotVerification) Encode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode botVerification#f93cd45c as nil") } buf.PutID(BotVerificationTypeID) return b.EncodeBare(buf) } // EncodeBare implements bin.BareEncoder. func (b *BotVerification) EncodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode botVerification#f93cd45c as nil") } buf.PutLong(b.BotID) buf.PutLong(b.Icon) buf.PutString(b.Description) return nil } // Decode implements bin.Decoder. func (b *BotVerification) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode botVerification#f93cd45c to nil") } if err := buf.ConsumeID(BotVerificationTypeID); err != nil { return fmt.Errorf("unable to decode botVerification#f93cd45c: %w", err) } return b.DecodeBare(buf) } // DecodeBare implements bin.BareDecoder. func (b *BotVerification) DecodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode botVerification#f93cd45c to nil") } { value, err := buf.Long() if err != nil { return fmt.Errorf("unable to decode botVerification#f93cd45c: field bot_id: %w", err) } b.BotID = value } { value, err := buf.Long() if err != nil { return fmt.Errorf("unable to decode botVerification#f93cd45c: field icon: %w", err) } b.Icon = value } { value, err := buf.String() if err != nil { return fmt.Errorf("unable to decode botVerification#f93cd45c: field description: %w", err) } b.Description = value } return nil } // GetBotID returns value of BotID field. func (b *BotVerification) GetBotID() (value int64) { if b == nil { return } return b.BotID } // GetIcon returns value of Icon field. func (b *BotVerification) GetIcon() (value int64) { if b == nil { return } return b.Icon } // GetDescription returns value of Description field. func (b *BotVerification) GetDescription() (value string) { if b == nil { return } return b.Description }