// 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{} ) // VideoChat represents TL type `videoChat#ae158d28`. type VideoChat struct { // Group call identifier of an active video chat; 0 if none. Full information about the // video chat can be received through the method getGroupCall GroupCallID int32 // True, if the video chat has participants HasParticipants bool // Default group call participant identifier to join the video chat; may be null DefaultParticipantID MessageSenderClass } // VideoChatTypeID is TL type id of VideoChat. const VideoChatTypeID = 0xae158d28 // Ensuring interfaces in compile-time for VideoChat. var ( _ bin.Encoder = &VideoChat{} _ bin.Decoder = &VideoChat{} _ bin.BareEncoder = &VideoChat{} _ bin.BareDecoder = &VideoChat{} ) func (v *VideoChat) Zero() bool { if v == nil { return true } if !(v.GroupCallID == 0) { return false } if !(v.HasParticipants == false) { return false } if !(v.DefaultParticipantID == nil) { return false } return true } // String implements fmt.Stringer. func (v *VideoChat) String() string { if v == nil { return "VideoChat(nil)" } type Alias VideoChat return fmt.Sprintf("VideoChat%+v", Alias(*v)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*VideoChat) TypeID() uint32 { return VideoChatTypeID } // TypeName returns name of type in TL schema. func (*VideoChat) TypeName() string { return "videoChat" } // TypeInfo returns info about TL type. func (v *VideoChat) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "videoChat", ID: VideoChatTypeID, } if v == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "GroupCallID", SchemaName: "group_call_id", }, { Name: "HasParticipants", SchemaName: "has_participants", }, { Name: "DefaultParticipantID", SchemaName: "default_participant_id", }, } return typ } // Encode implements bin.Encoder. func (v *VideoChat) Encode(b *bin.Buffer) error { if v == nil { return fmt.Errorf("can't encode videoChat#ae158d28 as nil") } b.PutID(VideoChatTypeID) return v.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (v *VideoChat) EncodeBare(b *bin.Buffer) error { if v == nil { return fmt.Errorf("can't encode videoChat#ae158d28 as nil") } b.PutInt32(v.GroupCallID) b.PutBool(v.HasParticipants) if v.DefaultParticipantID == nil { return fmt.Errorf("unable to encode videoChat#ae158d28: field default_participant_id is nil") } if err := v.DefaultParticipantID.Encode(b); err != nil { return fmt.Errorf("unable to encode videoChat#ae158d28: field default_participant_id: %w", err) } return nil } // Decode implements bin.Decoder. func (v *VideoChat) Decode(b *bin.Buffer) error { if v == nil { return fmt.Errorf("can't decode videoChat#ae158d28 to nil") } if err := b.ConsumeID(VideoChatTypeID); err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: %w", err) } return v.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (v *VideoChat) DecodeBare(b *bin.Buffer) error { if v == nil { return fmt.Errorf("can't decode videoChat#ae158d28 to nil") } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field group_call_id: %w", err) } v.GroupCallID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field has_participants: %w", err) } v.HasParticipants = value } { value, err := DecodeMessageSender(b) if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field default_participant_id: %w", err) } v.DefaultParticipantID = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (v *VideoChat) EncodeTDLibJSON(b tdjson.Encoder) error { if v == nil { return fmt.Errorf("can't encode videoChat#ae158d28 as nil") } b.ObjStart() b.PutID("videoChat") b.Comma() b.FieldStart("group_call_id") b.PutInt32(v.GroupCallID) b.Comma() b.FieldStart("has_participants") b.PutBool(v.HasParticipants) b.Comma() b.FieldStart("default_participant_id") if v.DefaultParticipantID == nil { return fmt.Errorf("unable to encode videoChat#ae158d28: field default_participant_id is nil") } if err := v.DefaultParticipantID.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode videoChat#ae158d28: field default_participant_id: %w", err) } b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (v *VideoChat) DecodeTDLibJSON(b tdjson.Decoder) error { if v == nil { return fmt.Errorf("can't decode videoChat#ae158d28 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("videoChat"); err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: %w", err) } case "group_call_id": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field group_call_id: %w", err) } v.GroupCallID = value case "has_participants": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field has_participants: %w", err) } v.HasParticipants = value case "default_participant_id": value, err := DecodeTDLibJSONMessageSender(b) if err != nil { return fmt.Errorf("unable to decode videoChat#ae158d28: field default_participant_id: %w", err) } v.DefaultParticipantID = value default: return b.Skip() } return nil }) } // GetGroupCallID returns value of GroupCallID field. func (v *VideoChat) GetGroupCallID() (value int32) { if v == nil { return } return v.GroupCallID } // GetHasParticipants returns value of HasParticipants field. func (v *VideoChat) GetHasParticipants() (value bool) { if v == nil { return } return v.HasParticipants } // GetDefaultParticipantID returns value of DefaultParticipantID field. func (v *VideoChat) GetDefaultParticipantID() (value MessageSenderClass) { if v == nil { return } return v.DefaultParticipantID }