// 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{} ) // GroupCallRecentSpeaker represents TL type `groupCallRecentSpeaker#6c73a9cc`. type GroupCallRecentSpeaker struct { // Group call participant identifier ParticipantID MessageSenderClass // True, is the user has spoken recently IsSpeaking bool } // GroupCallRecentSpeakerTypeID is TL type id of GroupCallRecentSpeaker. const GroupCallRecentSpeakerTypeID = 0x6c73a9cc // Ensuring interfaces in compile-time for GroupCallRecentSpeaker. var ( _ bin.Encoder = &GroupCallRecentSpeaker{} _ bin.Decoder = &GroupCallRecentSpeaker{} _ bin.BareEncoder = &GroupCallRecentSpeaker{} _ bin.BareDecoder = &GroupCallRecentSpeaker{} ) func (g *GroupCallRecentSpeaker) Zero() bool { if g == nil { return true } if !(g.ParticipantID == nil) { return false } if !(g.IsSpeaking == false) { return false } return true } // String implements fmt.Stringer. func (g *GroupCallRecentSpeaker) String() string { if g == nil { return "GroupCallRecentSpeaker(nil)" } type Alias GroupCallRecentSpeaker return fmt.Sprintf("GroupCallRecentSpeaker%+v", Alias(*g)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*GroupCallRecentSpeaker) TypeID() uint32 { return GroupCallRecentSpeakerTypeID } // TypeName returns name of type in TL schema. func (*GroupCallRecentSpeaker) TypeName() string { return "groupCallRecentSpeaker" } // TypeInfo returns info about TL type. func (g *GroupCallRecentSpeaker) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "groupCallRecentSpeaker", ID: GroupCallRecentSpeakerTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ParticipantID", SchemaName: "participant_id", }, { Name: "IsSpeaking", SchemaName: "is_speaking", }, } return typ } // Encode implements bin.Encoder. func (g *GroupCallRecentSpeaker) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode groupCallRecentSpeaker#6c73a9cc as nil") } b.PutID(GroupCallRecentSpeakerTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *GroupCallRecentSpeaker) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode groupCallRecentSpeaker#6c73a9cc as nil") } if g.ParticipantID == nil { return fmt.Errorf("unable to encode groupCallRecentSpeaker#6c73a9cc: field participant_id is nil") } if err := g.ParticipantID.Encode(b); err != nil { return fmt.Errorf("unable to encode groupCallRecentSpeaker#6c73a9cc: field participant_id: %w", err) } b.PutBool(g.IsSpeaking) return nil } // Decode implements bin.Decoder. func (g *GroupCallRecentSpeaker) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode groupCallRecentSpeaker#6c73a9cc to nil") } if err := b.ConsumeID(GroupCallRecentSpeakerTypeID); err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *GroupCallRecentSpeaker) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode groupCallRecentSpeaker#6c73a9cc to nil") } { value, err := DecodeMessageSender(b) if err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: field participant_id: %w", err) } g.ParticipantID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: field is_speaking: %w", err) } g.IsSpeaking = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GroupCallRecentSpeaker) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { return fmt.Errorf("can't encode groupCallRecentSpeaker#6c73a9cc as nil") } b.ObjStart() b.PutID("groupCallRecentSpeaker") b.Comma() b.FieldStart("participant_id") if g.ParticipantID == nil { return fmt.Errorf("unable to encode groupCallRecentSpeaker#6c73a9cc: field participant_id is nil") } if err := g.ParticipantID.EncodeTDLibJSON(b); err != nil { return fmt.Errorf("unable to encode groupCallRecentSpeaker#6c73a9cc: field participant_id: %w", err) } b.Comma() b.FieldStart("is_speaking") b.PutBool(g.IsSpeaking) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GroupCallRecentSpeaker) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { return fmt.Errorf("can't decode groupCallRecentSpeaker#6c73a9cc to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("groupCallRecentSpeaker"); err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: %w", err) } case "participant_id": value, err := DecodeTDLibJSONMessageSender(b) if err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: field participant_id: %w", err) } g.ParticipantID = value case "is_speaking": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode groupCallRecentSpeaker#6c73a9cc: field is_speaking: %w", err) } g.IsSpeaking = value default: return b.Skip() } return nil }) } // GetParticipantID returns value of ParticipantID field. func (g *GroupCallRecentSpeaker) GetParticipantID() (value MessageSenderClass) { if g == nil { return } return g.ParticipantID } // GetIsSpeaking returns value of IsSpeaking field. func (g *GroupCallRecentSpeaker) GetIsSpeaking() (value bool) { if g == nil { return } return g.IsSpeaking }