// 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{} ) // ReadParticipantDate represents TL type `readParticipantDate#4a4ff172`. // Contains info about when a certain participant has read a message // // See https://core.telegram.org/constructor/readParticipantDate for reference. type ReadParticipantDate struct { // User ID UserID int64 // When the user read the message Date int } // ReadParticipantDateTypeID is TL type id of ReadParticipantDate. const ReadParticipantDateTypeID = 0x4a4ff172 // Ensuring interfaces in compile-time for ReadParticipantDate. var ( _ bin.Encoder = &ReadParticipantDate{} _ bin.Decoder = &ReadParticipantDate{} _ bin.BareEncoder = &ReadParticipantDate{} _ bin.BareDecoder = &ReadParticipantDate{} ) func (r *ReadParticipantDate) Zero() bool { if r == nil { return true } if !(r.UserID == 0) { return false } if !(r.Date == 0) { return false } return true } // String implements fmt.Stringer. func (r *ReadParticipantDate) String() string { if r == nil { return "ReadParticipantDate(nil)" } type Alias ReadParticipantDate return fmt.Sprintf("ReadParticipantDate%+v", Alias(*r)) } // FillFrom fills ReadParticipantDate from given interface. func (r *ReadParticipantDate) FillFrom(from interface { GetUserID() (value int64) GetDate() (value int) }) { r.UserID = from.GetUserID() r.Date = from.GetDate() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ReadParticipantDate) TypeID() uint32 { return ReadParticipantDateTypeID } // TypeName returns name of type in TL schema. func (*ReadParticipantDate) TypeName() string { return "readParticipantDate" } // TypeInfo returns info about TL type. func (r *ReadParticipantDate) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "readParticipantDate", ID: ReadParticipantDateTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "UserID", SchemaName: "user_id", }, { Name: "Date", SchemaName: "date", }, } return typ } // Encode implements bin.Encoder. func (r *ReadParticipantDate) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode readParticipantDate#4a4ff172 as nil") } b.PutID(ReadParticipantDateTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ReadParticipantDate) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode readParticipantDate#4a4ff172 as nil") } b.PutLong(r.UserID) b.PutInt(r.Date) return nil } // Decode implements bin.Decoder. func (r *ReadParticipantDate) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode readParticipantDate#4a4ff172 to nil") } if err := b.ConsumeID(ReadParticipantDateTypeID); err != nil { return fmt.Errorf("unable to decode readParticipantDate#4a4ff172: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ReadParticipantDate) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode readParticipantDate#4a4ff172 to nil") } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode readParticipantDate#4a4ff172: field user_id: %w", err) } r.UserID = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode readParticipantDate#4a4ff172: field date: %w", err) } r.Date = value } return nil } // GetUserID returns value of UserID field. func (r *ReadParticipantDate) GetUserID() (value int64) { if r == nil { return } return r.UserID } // GetDate returns value of Date field. func (r *ReadParticipantDate) GetDate() (value int) { if r == nil { return } return r.Date }