// 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{} ) // AddedReaction represents TL type `addedReaction#4b04819d`. type AddedReaction struct { // Type of the reaction Type ReactionTypeClass // Identifier of the chat member, applied the reaction SenderID MessageSenderClass // True, if the reaction was added by the current user IsOutgoing bool // Point in time (Unix timestamp) when the reaction was added Date int32 } // AddedReactionTypeID is TL type id of AddedReaction. const AddedReactionTypeID = 0x4b04819d // Ensuring interfaces in compile-time for AddedReaction. var ( _ bin.Encoder = &AddedReaction{} _ bin.Decoder = &AddedReaction{} _ bin.BareEncoder = &AddedReaction{} _ bin.BareDecoder = &AddedReaction{} ) func (a *AddedReaction) Zero() bool { if a == nil { return true } if !(a.Type == nil) { return false } if !(a.SenderID == nil) { return false } if !(a.IsOutgoing == false) { return false } if !(a.Date == 0) { return false } return true } // String implements fmt.Stringer. func (a *AddedReaction) String() string { if a == nil { return "AddedReaction(nil)" } type Alias AddedReaction return fmt.Sprintf("AddedReaction%+v", Alias(*a)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*AddedReaction) TypeID() uint32 { return AddedReactionTypeID } // TypeName returns name of type in TL schema. func (*AddedReaction) TypeName() string { return "addedReaction" } // TypeInfo returns info about TL type. func (a *AddedReaction) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "addedReaction", ID: AddedReactionTypeID, } if a == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Type", SchemaName: "type", }, { Name: "SenderID", SchemaName: "sender_id", }, { Name: "IsOutgoing", SchemaName: "is_outgoing", }, { Name: "Date", SchemaName: "date", }, } return typ } // Encode implements bin.Encoder. func (a *AddedReaction) Encode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode addedReaction#4b04819d as nil") } b.PutID(AddedReactionTypeID) return a.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (a *AddedReaction) EncodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode addedReaction#4b04819d as nil") } if a.Type == nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field type is nil") } if err := a.Type.Encode(b); err != nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field type: %w", err) } if a.SenderID == nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field sender_id is nil") } if err := a.SenderID.Encode(b); err != nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field sender_id: %w", err) } b.PutBool(a.IsOutgoing) b.PutInt32(a.Date) return nil } // Decode implements bin.Decoder. func (a *AddedReaction) Decode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode addedReaction#4b04819d to nil") } if err := b.ConsumeID(AddedReactionTypeID); err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: %w", err) } return a.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (a *AddedReaction) DecodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode addedReaction#4b04819d to nil") } { value, err := DecodeReactionType(b) if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field type: %w", err) } a.Type = value } { value, err := DecodeMessageSender(b) if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field sender_id: %w", err) } a.SenderID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field is_outgoing: %w", err) } a.IsOutgoing = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field date: %w", err) } a.Date = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (a *AddedReaction) EncodeTDLibJSON(b tdjson.Encoder) error { if a == nil { return fmt.Errorf("can't encode addedReaction#4b04819d as nil") } b.ObjStart() b.PutID("addedReaction") b.Comma() b.FieldStart("type") if a.Type == nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field type is nil") } if err := a.Type.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field type: %w", err) } b.Comma() b.FieldStart("sender_id") if a.SenderID == nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field sender_id is nil") } if err := a.SenderID.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode addedReaction#4b04819d: field sender_id: %w", err) } b.Comma() b.FieldStart("is_outgoing") b.PutBool(a.IsOutgoing) b.Comma() b.FieldStart("date") b.PutInt32(a.Date) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (a *AddedReaction) DecodeTDLibJSON(b tdjson.Decoder) error { if a == nil { return fmt.Errorf("can't decode addedReaction#4b04819d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("addedReaction"); err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: %w", err) } case "type": value, err := DecodeTDLibJSONReactionType(b) if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field type: %w", err) } a.Type = value case "sender_id": value, err := DecodeTDLibJSONMessageSender(b) if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field sender_id: %w", err) } a.SenderID = value case "is_outgoing": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field is_outgoing: %w", err) } a.IsOutgoing = value case "date": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode addedReaction#4b04819d: field date: %w", err) } a.Date = value default: return b.Skip() } return nil }) } // GetType returns value of Type field. func (a *AddedReaction) GetType() (value ReactionTypeClass) { if a == nil { return } return a.Type } // GetSenderID returns value of SenderID field. func (a *AddedReaction) GetSenderID() (value MessageSenderClass) { if a == nil { return } return a.SenderID } // GetIsOutgoing returns value of IsOutgoing field. func (a *AddedReaction) GetIsOutgoing() (value bool) { if a == nil { return } return a.IsOutgoing } // GetDate returns value of Date field. func (a *AddedReaction) GetDate() (value int32) { if a == nil { return } return a.Date }