// 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{} ) // StoryInteraction represents TL type `storyInteraction#d624d222`. type StoryInteraction struct { // Identifier of the user or chat that made the interaction ActorID MessageSenderClass // Approximate point in time (Unix timestamp) when the interaction happened InteractionDate int32 // Block list to which the actor is added; may be null if none or for chat stories BlockList BlockListClass // Type of the interaction Type StoryInteractionTypeClass } // StoryInteractionTypeID is TL type id of StoryInteraction. const StoryInteractionTypeID = 0xd624d222 // Ensuring interfaces in compile-time for StoryInteraction. var ( _ bin.Encoder = &StoryInteraction{} _ bin.Decoder = &StoryInteraction{} _ bin.BareEncoder = &StoryInteraction{} _ bin.BareDecoder = &StoryInteraction{} ) func (s *StoryInteraction) Zero() bool { if s == nil { return true } if !(s.ActorID == nil) { return false } if !(s.InteractionDate == 0) { return false } if !(s.BlockList == nil) { return false } if !(s.Type == nil) { return false } return true } // String implements fmt.Stringer. func (s *StoryInteraction) String() string { if s == nil { return "StoryInteraction(nil)" } type Alias StoryInteraction return fmt.Sprintf("StoryInteraction%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*StoryInteraction) TypeID() uint32 { return StoryInteractionTypeID } // TypeName returns name of type in TL schema. func (*StoryInteraction) TypeName() string { return "storyInteraction" } // TypeInfo returns info about TL type. func (s *StoryInteraction) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "storyInteraction", ID: StoryInteractionTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ActorID", SchemaName: "actor_id", }, { Name: "InteractionDate", SchemaName: "interaction_date", }, { Name: "BlockList", SchemaName: "block_list", }, { Name: "Type", SchemaName: "type", }, } return typ } // Encode implements bin.Encoder. func (s *StoryInteraction) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode storyInteraction#d624d222 as nil") } b.PutID(StoryInteractionTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *StoryInteraction) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode storyInteraction#d624d222 as nil") } if s.ActorID == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field actor_id is nil") } if err := s.ActorID.Encode(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field actor_id: %w", err) } b.PutInt32(s.InteractionDate) if s.BlockList == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field block_list is nil") } if err := s.BlockList.Encode(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field block_list: %w", err) } if s.Type == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field type is nil") } if err := s.Type.Encode(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field type: %w", err) } return nil } // Decode implements bin.Decoder. func (s *StoryInteraction) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode storyInteraction#d624d222 to nil") } if err := b.ConsumeID(StoryInteractionTypeID); err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *StoryInteraction) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode storyInteraction#d624d222 to nil") } { value, err := DecodeMessageSender(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field actor_id: %w", err) } s.ActorID = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field interaction_date: %w", err) } s.InteractionDate = value } { value, err := DecodeBlockList(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field block_list: %w", err) } s.BlockList = value } { value, err := DecodeStoryInteractionType(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field type: %w", err) } s.Type = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StoryInteraction) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode storyInteraction#d624d222 as nil") } b.ObjStart() b.PutID("storyInteraction") b.Comma() b.FieldStart("actor_id") if s.ActorID == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field actor_id is nil") } if err := s.ActorID.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field actor_id: %w", err) } b.Comma() b.FieldStart("interaction_date") b.PutInt32(s.InteractionDate) b.Comma() b.FieldStart("block_list") if s.BlockList == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field block_list is nil") } if err := s.BlockList.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field block_list: %w", err) } b.Comma() b.FieldStart("type") if s.Type == nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field type is nil") } if err := s.Type.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode storyInteraction#d624d222: field type: %w", err) } b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StoryInteraction) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode storyInteraction#d624d222 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("storyInteraction"); err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: %w", err) } case "actor_id": value, err := DecodeTDLibJSONMessageSender(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field actor_id: %w", err) } s.ActorID = value case "interaction_date": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field interaction_date: %w", err) } s.InteractionDate = value case "block_list": value, err := DecodeTDLibJSONBlockList(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field block_list: %w", err) } s.BlockList = value case "type": value, err := DecodeTDLibJSONStoryInteractionType(b) if err != nil { return fmt.Errorf("unable to decode storyInteraction#d624d222: field type: %w", err) } s.Type = value default: return b.Skip() } return nil }) } // GetActorID returns value of ActorID field. func (s *StoryInteraction) GetActorID() (value MessageSenderClass) { if s == nil { return } return s.ActorID } // GetInteractionDate returns value of InteractionDate field. func (s *StoryInteraction) GetInteractionDate() (value int32) { if s == nil { return } return s.InteractionDate } // GetBlockList returns value of BlockList field. func (s *StoryInteraction) GetBlockList() (value BlockListClass) { if s == nil { return } return s.BlockList } // GetType returns value of Type field. func (s *StoryInteraction) GetType() (value StoryInteractionTypeClass) { if s == nil { return } return s.Type }