Files
mautrix-telegram/pkg/gotd/tg/tl_phone_call_gen.go
T
2025-12-03 17:11:20 +02:00

2404 lines
54 KiB
Go
Generated

// 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{}
)
// PhoneCallEmpty represents TL type `phoneCallEmpty#5366c915`.
// Empty constructor
//
// See https://core.telegram.org/constructor/phoneCallEmpty for reference.
type PhoneCallEmpty struct {
// Call ID
ID int64
}
// PhoneCallEmptyTypeID is TL type id of PhoneCallEmpty.
const PhoneCallEmptyTypeID = 0x5366c915
// construct implements constructor of PhoneCallClass.
func (p PhoneCallEmpty) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCallEmpty.
var (
_ bin.Encoder = &PhoneCallEmpty{}
_ bin.Decoder = &PhoneCallEmpty{}
_ bin.BareEncoder = &PhoneCallEmpty{}
_ bin.BareDecoder = &PhoneCallEmpty{}
_ PhoneCallClass = &PhoneCallEmpty{}
)
func (p *PhoneCallEmpty) Zero() bool {
if p == nil {
return true
}
if !(p.ID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCallEmpty) String() string {
if p == nil {
return "PhoneCallEmpty(nil)"
}
type Alias PhoneCallEmpty
return fmt.Sprintf("PhoneCallEmpty%+v", Alias(*p))
}
// FillFrom fills PhoneCallEmpty from given interface.
func (p *PhoneCallEmpty) FillFrom(from interface {
GetID() (value int64)
}) {
p.ID = from.GetID()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallEmpty) TypeID() uint32 {
return PhoneCallEmptyTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCallEmpty) TypeName() string {
return "phoneCallEmpty"
}
// TypeInfo returns info about TL type.
func (p *PhoneCallEmpty) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCallEmpty",
ID: PhoneCallEmptyTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PhoneCallEmpty) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallEmpty#5366c915 as nil")
}
b.PutID(PhoneCallEmptyTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCallEmpty) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallEmpty#5366c915 as nil")
}
b.PutLong(p.ID)
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCallEmpty) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallEmpty#5366c915 to nil")
}
if err := b.ConsumeID(PhoneCallEmptyTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCallEmpty#5366c915: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCallEmpty) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallEmpty#5366c915 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallEmpty#5366c915: field id: %w", err)
}
p.ID = value
}
return nil
}
// GetID returns value of ID field.
func (p *PhoneCallEmpty) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// PhoneCallWaiting represents TL type `phoneCallWaiting#c5226f17`.
// Incoming phone call
//
// See https://core.telegram.org/constructor/phoneCallWaiting for reference.
type PhoneCallWaiting struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Is this a video call
Video bool
// Call ID
ID int64
// Access hash
AccessHash int64
// Date
Date int
// Admin ID
AdminID int64
// Participant ID
ParticipantID int64
// Phone call protocol info
Protocol PhoneCallProtocol
// When was the phone call received
//
// Use SetReceiveDate and GetReceiveDate helpers.
ReceiveDate int
}
// PhoneCallWaitingTypeID is TL type id of PhoneCallWaiting.
const PhoneCallWaitingTypeID = 0xc5226f17
// construct implements constructor of PhoneCallClass.
func (p PhoneCallWaiting) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCallWaiting.
var (
_ bin.Encoder = &PhoneCallWaiting{}
_ bin.Decoder = &PhoneCallWaiting{}
_ bin.BareEncoder = &PhoneCallWaiting{}
_ bin.BareDecoder = &PhoneCallWaiting{}
_ PhoneCallClass = &PhoneCallWaiting{}
)
func (p *PhoneCallWaiting) Zero() bool {
if p == nil {
return true
}
if !(p.Flags.Zero()) {
return false
}
if !(p.Video == false) {
return false
}
if !(p.ID == 0) {
return false
}
if !(p.AccessHash == 0) {
return false
}
if !(p.Date == 0) {
return false
}
if !(p.AdminID == 0) {
return false
}
if !(p.ParticipantID == 0) {
return false
}
if !(p.Protocol.Zero()) {
return false
}
if !(p.ReceiveDate == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCallWaiting) String() string {
if p == nil {
return "PhoneCallWaiting(nil)"
}
type Alias PhoneCallWaiting
return fmt.Sprintf("PhoneCallWaiting%+v", Alias(*p))
}
// FillFrom fills PhoneCallWaiting from given interface.
func (p *PhoneCallWaiting) FillFrom(from interface {
GetVideo() (value bool)
GetID() (value int64)
GetAccessHash() (value int64)
GetDate() (value int)
GetAdminID() (value int64)
GetParticipantID() (value int64)
GetProtocol() (value PhoneCallProtocol)
GetReceiveDate() (value int, ok bool)
}) {
p.Video = from.GetVideo()
p.ID = from.GetID()
p.AccessHash = from.GetAccessHash()
p.Date = from.GetDate()
p.AdminID = from.GetAdminID()
p.ParticipantID = from.GetParticipantID()
p.Protocol = from.GetProtocol()
if val, ok := from.GetReceiveDate(); ok {
p.ReceiveDate = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallWaiting) TypeID() uint32 {
return PhoneCallWaitingTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCallWaiting) TypeName() string {
return "phoneCallWaiting"
}
// TypeInfo returns info about TL type.
func (p *PhoneCallWaiting) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCallWaiting",
ID: PhoneCallWaitingTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Video",
SchemaName: "video",
Null: !p.Flags.Has(6),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "AdminID",
SchemaName: "admin_id",
},
{
Name: "ParticipantID",
SchemaName: "participant_id",
},
{
Name: "Protocol",
SchemaName: "protocol",
},
{
Name: "ReceiveDate",
SchemaName: "receive_date",
Null: !p.Flags.Has(0),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (p *PhoneCallWaiting) SetFlags() {
if !(p.Video == false) {
p.Flags.Set(6)
}
if !(p.ReceiveDate == 0) {
p.Flags.Set(0)
}
}
// Encode implements bin.Encoder.
func (p *PhoneCallWaiting) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallWaiting#c5226f17 as nil")
}
b.PutID(PhoneCallWaitingTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCallWaiting) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallWaiting#c5226f17 as nil")
}
p.SetFlags()
if err := p.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallWaiting#c5226f17: field flags: %w", err)
}
b.PutLong(p.ID)
b.PutLong(p.AccessHash)
b.PutInt(p.Date)
b.PutLong(p.AdminID)
b.PutLong(p.ParticipantID)
if err := p.Protocol.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallWaiting#c5226f17: field protocol: %w", err)
}
if p.Flags.Has(0) {
b.PutInt(p.ReceiveDate)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCallWaiting) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallWaiting#c5226f17 to nil")
}
if err := b.ConsumeID(PhoneCallWaitingTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCallWaiting) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallWaiting#c5226f17 to nil")
}
{
if err := p.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field flags: %w", err)
}
}
p.Video = p.Flags.Has(6)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field id: %w", err)
}
p.ID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field access_hash: %w", err)
}
p.AccessHash = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field date: %w", err)
}
p.Date = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field admin_id: %w", err)
}
p.AdminID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field participant_id: %w", err)
}
p.ParticipantID = value
}
{
if err := p.Protocol.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field protocol: %w", err)
}
}
if p.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCallWaiting#c5226f17: field receive_date: %w", err)
}
p.ReceiveDate = value
}
return nil
}
// SetVideo sets value of Video conditional field.
func (p *PhoneCallWaiting) SetVideo(value bool) {
if value {
p.Flags.Set(6)
p.Video = true
} else {
p.Flags.Unset(6)
p.Video = false
}
}
// GetVideo returns value of Video conditional field.
func (p *PhoneCallWaiting) GetVideo() (value bool) {
if p == nil {
return
}
return p.Flags.Has(6)
}
// GetID returns value of ID field.
func (p *PhoneCallWaiting) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// GetAccessHash returns value of AccessHash field.
func (p *PhoneCallWaiting) GetAccessHash() (value int64) {
if p == nil {
return
}
return p.AccessHash
}
// GetDate returns value of Date field.
func (p *PhoneCallWaiting) GetDate() (value int) {
if p == nil {
return
}
return p.Date
}
// GetAdminID returns value of AdminID field.
func (p *PhoneCallWaiting) GetAdminID() (value int64) {
if p == nil {
return
}
return p.AdminID
}
// GetParticipantID returns value of ParticipantID field.
func (p *PhoneCallWaiting) GetParticipantID() (value int64) {
if p == nil {
return
}
return p.ParticipantID
}
// GetProtocol returns value of Protocol field.
func (p *PhoneCallWaiting) GetProtocol() (value PhoneCallProtocol) {
if p == nil {
return
}
return p.Protocol
}
// SetReceiveDate sets value of ReceiveDate conditional field.
func (p *PhoneCallWaiting) SetReceiveDate(value int) {
p.Flags.Set(0)
p.ReceiveDate = value
}
// GetReceiveDate returns value of ReceiveDate conditional field and
// boolean which is true if field was set.
func (p *PhoneCallWaiting) GetReceiveDate() (value int, ok bool) {
if p == nil {
return
}
if !p.Flags.Has(0) {
return value, false
}
return p.ReceiveDate, true
}
// PhoneCallRequested represents TL type `phoneCallRequested#14b0ed0c`.
// Requested phone call
//
// See https://core.telegram.org/constructor/phoneCallRequested for reference.
type PhoneCallRequested struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this is a video call
Video bool
// Phone call ID
ID int64
// Access hash
AccessHash int64
// When was the phone call created
Date int
// ID of the creator of the phone call
AdminID int64
// ID of the other participant of the phone call
ParticipantID int64
// Parameter for key exchange¹
//
// Links:
// 1) https://core.telegram.org/api/end-to-end/voice-calls
GAHash []byte
// Call protocol info to be passed to libtgvoip
Protocol PhoneCallProtocol
}
// PhoneCallRequestedTypeID is TL type id of PhoneCallRequested.
const PhoneCallRequestedTypeID = 0x14b0ed0c
// construct implements constructor of PhoneCallClass.
func (p PhoneCallRequested) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCallRequested.
var (
_ bin.Encoder = &PhoneCallRequested{}
_ bin.Decoder = &PhoneCallRequested{}
_ bin.BareEncoder = &PhoneCallRequested{}
_ bin.BareDecoder = &PhoneCallRequested{}
_ PhoneCallClass = &PhoneCallRequested{}
)
func (p *PhoneCallRequested) Zero() bool {
if p == nil {
return true
}
if !(p.Flags.Zero()) {
return false
}
if !(p.Video == false) {
return false
}
if !(p.ID == 0) {
return false
}
if !(p.AccessHash == 0) {
return false
}
if !(p.Date == 0) {
return false
}
if !(p.AdminID == 0) {
return false
}
if !(p.ParticipantID == 0) {
return false
}
if !(p.GAHash == nil) {
return false
}
if !(p.Protocol.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCallRequested) String() string {
if p == nil {
return "PhoneCallRequested(nil)"
}
type Alias PhoneCallRequested
return fmt.Sprintf("PhoneCallRequested%+v", Alias(*p))
}
// FillFrom fills PhoneCallRequested from given interface.
func (p *PhoneCallRequested) FillFrom(from interface {
GetVideo() (value bool)
GetID() (value int64)
GetAccessHash() (value int64)
GetDate() (value int)
GetAdminID() (value int64)
GetParticipantID() (value int64)
GetGAHash() (value []byte)
GetProtocol() (value PhoneCallProtocol)
}) {
p.Video = from.GetVideo()
p.ID = from.GetID()
p.AccessHash = from.GetAccessHash()
p.Date = from.GetDate()
p.AdminID = from.GetAdminID()
p.ParticipantID = from.GetParticipantID()
p.GAHash = from.GetGAHash()
p.Protocol = from.GetProtocol()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallRequested) TypeID() uint32 {
return PhoneCallRequestedTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCallRequested) TypeName() string {
return "phoneCallRequested"
}
// TypeInfo returns info about TL type.
func (p *PhoneCallRequested) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCallRequested",
ID: PhoneCallRequestedTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Video",
SchemaName: "video",
Null: !p.Flags.Has(6),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "AdminID",
SchemaName: "admin_id",
},
{
Name: "ParticipantID",
SchemaName: "participant_id",
},
{
Name: "GAHash",
SchemaName: "g_a_hash",
},
{
Name: "Protocol",
SchemaName: "protocol",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (p *PhoneCallRequested) SetFlags() {
if !(p.Video == false) {
p.Flags.Set(6)
}
}
// Encode implements bin.Encoder.
func (p *PhoneCallRequested) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallRequested#14b0ed0c as nil")
}
b.PutID(PhoneCallRequestedTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCallRequested) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallRequested#14b0ed0c as nil")
}
p.SetFlags()
if err := p.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallRequested#14b0ed0c: field flags: %w", err)
}
b.PutLong(p.ID)
b.PutLong(p.AccessHash)
b.PutInt(p.Date)
b.PutLong(p.AdminID)
b.PutLong(p.ParticipantID)
b.PutBytes(p.GAHash)
if err := p.Protocol.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallRequested#14b0ed0c: field protocol: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCallRequested) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallRequested#14b0ed0c to nil")
}
if err := b.ConsumeID(PhoneCallRequestedTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCallRequested) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallRequested#14b0ed0c to nil")
}
{
if err := p.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field flags: %w", err)
}
}
p.Video = p.Flags.Has(6)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field id: %w", err)
}
p.ID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field access_hash: %w", err)
}
p.AccessHash = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field date: %w", err)
}
p.Date = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field admin_id: %w", err)
}
p.AdminID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field participant_id: %w", err)
}
p.ParticipantID = value
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field g_a_hash: %w", err)
}
p.GAHash = value
}
{
if err := p.Protocol.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallRequested#14b0ed0c: field protocol: %w", err)
}
}
return nil
}
// SetVideo sets value of Video conditional field.
func (p *PhoneCallRequested) SetVideo(value bool) {
if value {
p.Flags.Set(6)
p.Video = true
} else {
p.Flags.Unset(6)
p.Video = false
}
}
// GetVideo returns value of Video conditional field.
func (p *PhoneCallRequested) GetVideo() (value bool) {
if p == nil {
return
}
return p.Flags.Has(6)
}
// GetID returns value of ID field.
func (p *PhoneCallRequested) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// GetAccessHash returns value of AccessHash field.
func (p *PhoneCallRequested) GetAccessHash() (value int64) {
if p == nil {
return
}
return p.AccessHash
}
// GetDate returns value of Date field.
func (p *PhoneCallRequested) GetDate() (value int) {
if p == nil {
return
}
return p.Date
}
// GetAdminID returns value of AdminID field.
func (p *PhoneCallRequested) GetAdminID() (value int64) {
if p == nil {
return
}
return p.AdminID
}
// GetParticipantID returns value of ParticipantID field.
func (p *PhoneCallRequested) GetParticipantID() (value int64) {
if p == nil {
return
}
return p.ParticipantID
}
// GetGAHash returns value of GAHash field.
func (p *PhoneCallRequested) GetGAHash() (value []byte) {
if p == nil {
return
}
return p.GAHash
}
// GetProtocol returns value of Protocol field.
func (p *PhoneCallRequested) GetProtocol() (value PhoneCallProtocol) {
if p == nil {
return
}
return p.Protocol
}
// PhoneCallAccepted represents TL type `phoneCallAccepted#3660c311`.
// An accepted phone call
//
// See https://core.telegram.org/constructor/phoneCallAccepted for reference.
type PhoneCallAccepted struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this is a video call
Video bool
// ID of accepted phone call
ID int64
// Access hash of phone call
AccessHash int64
// When was the call accepted
Date int
// ID of the call creator
AdminID int64
// ID of the other user in the call
ParticipantID int64
// B parameter for secure E2E phone call key exchange¹
//
// Links:
// 1) https://core.telegram.org/api/end-to-end/voice-calls
GB []byte
// Protocol to use for phone call
Protocol PhoneCallProtocol
}
// PhoneCallAcceptedTypeID is TL type id of PhoneCallAccepted.
const PhoneCallAcceptedTypeID = 0x3660c311
// construct implements constructor of PhoneCallClass.
func (p PhoneCallAccepted) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCallAccepted.
var (
_ bin.Encoder = &PhoneCallAccepted{}
_ bin.Decoder = &PhoneCallAccepted{}
_ bin.BareEncoder = &PhoneCallAccepted{}
_ bin.BareDecoder = &PhoneCallAccepted{}
_ PhoneCallClass = &PhoneCallAccepted{}
)
func (p *PhoneCallAccepted) Zero() bool {
if p == nil {
return true
}
if !(p.Flags.Zero()) {
return false
}
if !(p.Video == false) {
return false
}
if !(p.ID == 0) {
return false
}
if !(p.AccessHash == 0) {
return false
}
if !(p.Date == 0) {
return false
}
if !(p.AdminID == 0) {
return false
}
if !(p.ParticipantID == 0) {
return false
}
if !(p.GB == nil) {
return false
}
if !(p.Protocol.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCallAccepted) String() string {
if p == nil {
return "PhoneCallAccepted(nil)"
}
type Alias PhoneCallAccepted
return fmt.Sprintf("PhoneCallAccepted%+v", Alias(*p))
}
// FillFrom fills PhoneCallAccepted from given interface.
func (p *PhoneCallAccepted) FillFrom(from interface {
GetVideo() (value bool)
GetID() (value int64)
GetAccessHash() (value int64)
GetDate() (value int)
GetAdminID() (value int64)
GetParticipantID() (value int64)
GetGB() (value []byte)
GetProtocol() (value PhoneCallProtocol)
}) {
p.Video = from.GetVideo()
p.ID = from.GetID()
p.AccessHash = from.GetAccessHash()
p.Date = from.GetDate()
p.AdminID = from.GetAdminID()
p.ParticipantID = from.GetParticipantID()
p.GB = from.GetGB()
p.Protocol = from.GetProtocol()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallAccepted) TypeID() uint32 {
return PhoneCallAcceptedTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCallAccepted) TypeName() string {
return "phoneCallAccepted"
}
// TypeInfo returns info about TL type.
func (p *PhoneCallAccepted) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCallAccepted",
ID: PhoneCallAcceptedTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Video",
SchemaName: "video",
Null: !p.Flags.Has(6),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "AdminID",
SchemaName: "admin_id",
},
{
Name: "ParticipantID",
SchemaName: "participant_id",
},
{
Name: "GB",
SchemaName: "g_b",
},
{
Name: "Protocol",
SchemaName: "protocol",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (p *PhoneCallAccepted) SetFlags() {
if !(p.Video == false) {
p.Flags.Set(6)
}
}
// Encode implements bin.Encoder.
func (p *PhoneCallAccepted) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallAccepted#3660c311 as nil")
}
b.PutID(PhoneCallAcceptedTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCallAccepted) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallAccepted#3660c311 as nil")
}
p.SetFlags()
if err := p.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallAccepted#3660c311: field flags: %w", err)
}
b.PutLong(p.ID)
b.PutLong(p.AccessHash)
b.PutInt(p.Date)
b.PutLong(p.AdminID)
b.PutLong(p.ParticipantID)
b.PutBytes(p.GB)
if err := p.Protocol.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallAccepted#3660c311: field protocol: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCallAccepted) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallAccepted#3660c311 to nil")
}
if err := b.ConsumeID(PhoneCallAcceptedTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCallAccepted) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallAccepted#3660c311 to nil")
}
{
if err := p.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field flags: %w", err)
}
}
p.Video = p.Flags.Has(6)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field id: %w", err)
}
p.ID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field access_hash: %w", err)
}
p.AccessHash = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field date: %w", err)
}
p.Date = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field admin_id: %w", err)
}
p.AdminID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field participant_id: %w", err)
}
p.ParticipantID = value
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field g_b: %w", err)
}
p.GB = value
}
{
if err := p.Protocol.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallAccepted#3660c311: field protocol: %w", err)
}
}
return nil
}
// SetVideo sets value of Video conditional field.
func (p *PhoneCallAccepted) SetVideo(value bool) {
if value {
p.Flags.Set(6)
p.Video = true
} else {
p.Flags.Unset(6)
p.Video = false
}
}
// GetVideo returns value of Video conditional field.
func (p *PhoneCallAccepted) GetVideo() (value bool) {
if p == nil {
return
}
return p.Flags.Has(6)
}
// GetID returns value of ID field.
func (p *PhoneCallAccepted) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// GetAccessHash returns value of AccessHash field.
func (p *PhoneCallAccepted) GetAccessHash() (value int64) {
if p == nil {
return
}
return p.AccessHash
}
// GetDate returns value of Date field.
func (p *PhoneCallAccepted) GetDate() (value int) {
if p == nil {
return
}
return p.Date
}
// GetAdminID returns value of AdminID field.
func (p *PhoneCallAccepted) GetAdminID() (value int64) {
if p == nil {
return
}
return p.AdminID
}
// GetParticipantID returns value of ParticipantID field.
func (p *PhoneCallAccepted) GetParticipantID() (value int64) {
if p == nil {
return
}
return p.ParticipantID
}
// GetGB returns value of GB field.
func (p *PhoneCallAccepted) GetGB() (value []byte) {
if p == nil {
return
}
return p.GB
}
// GetProtocol returns value of Protocol field.
func (p *PhoneCallAccepted) GetProtocol() (value PhoneCallProtocol) {
if p == nil {
return
}
return p.Protocol
}
// PhoneCall represents TL type `phoneCall#30535af5`.
// Phone call
//
// See https://core.telegram.org/constructor/phoneCall for reference.
type PhoneCall struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether P2P connection to the other peer is allowed
P2PAllowed bool
// Whether this is a video call
Video bool
// If set, the other party supports upgrading of the call to a conference call¹.
//
// Links:
// 1) https://core.telegram.org/api/end-to-end/group-calls
ConferenceSupported bool
// Call ID
ID int64
// Access hash
AccessHash int64
// Date of creation of the call
Date int
// User ID of the creator of the call
AdminID int64
// User ID of the other participant in the call
ParticipantID int64
// Parameter for key exchange¹
//
// Links:
// 1) https://core.telegram.org/api/end-to-end/voice-calls
GAOrB []byte
// Key fingerprint¹
//
// Links:
// 1) https://core.telegram.org/api/end-to-end/voice-calls
KeyFingerprint int64
// Call protocol info to be passed to libtgvoip
Protocol PhoneCallProtocol
// List of endpoints the user can connect to exchange call data
Connections []PhoneConnectionClass
// When was the call actually started
StartDate int
// Custom JSON-encoded call parameters to be passed to tgcalls.
//
// Use SetCustomParameters and GetCustomParameters helpers.
CustomParameters DataJSON
}
// PhoneCallTypeID is TL type id of PhoneCall.
const PhoneCallTypeID = 0x30535af5
// construct implements constructor of PhoneCallClass.
func (p PhoneCall) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCall.
var (
_ bin.Encoder = &PhoneCall{}
_ bin.Decoder = &PhoneCall{}
_ bin.BareEncoder = &PhoneCall{}
_ bin.BareDecoder = &PhoneCall{}
_ PhoneCallClass = &PhoneCall{}
)
func (p *PhoneCall) Zero() bool {
if p == nil {
return true
}
if !(p.Flags.Zero()) {
return false
}
if !(p.P2PAllowed == false) {
return false
}
if !(p.Video == false) {
return false
}
if !(p.ConferenceSupported == false) {
return false
}
if !(p.ID == 0) {
return false
}
if !(p.AccessHash == 0) {
return false
}
if !(p.Date == 0) {
return false
}
if !(p.AdminID == 0) {
return false
}
if !(p.ParticipantID == 0) {
return false
}
if !(p.GAOrB == nil) {
return false
}
if !(p.KeyFingerprint == 0) {
return false
}
if !(p.Protocol.Zero()) {
return false
}
if !(p.Connections == nil) {
return false
}
if !(p.StartDate == 0) {
return false
}
if !(p.CustomParameters.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCall) String() string {
if p == nil {
return "PhoneCall(nil)"
}
type Alias PhoneCall
return fmt.Sprintf("PhoneCall%+v", Alias(*p))
}
// FillFrom fills PhoneCall from given interface.
func (p *PhoneCall) FillFrom(from interface {
GetP2PAllowed() (value bool)
GetVideo() (value bool)
GetConferenceSupported() (value bool)
GetID() (value int64)
GetAccessHash() (value int64)
GetDate() (value int)
GetAdminID() (value int64)
GetParticipantID() (value int64)
GetGAOrB() (value []byte)
GetKeyFingerprint() (value int64)
GetProtocol() (value PhoneCallProtocol)
GetConnections() (value []PhoneConnectionClass)
GetStartDate() (value int)
GetCustomParameters() (value DataJSON, ok bool)
}) {
p.P2PAllowed = from.GetP2PAllowed()
p.Video = from.GetVideo()
p.ConferenceSupported = from.GetConferenceSupported()
p.ID = from.GetID()
p.AccessHash = from.GetAccessHash()
p.Date = from.GetDate()
p.AdminID = from.GetAdminID()
p.ParticipantID = from.GetParticipantID()
p.GAOrB = from.GetGAOrB()
p.KeyFingerprint = from.GetKeyFingerprint()
p.Protocol = from.GetProtocol()
p.Connections = from.GetConnections()
p.StartDate = from.GetStartDate()
if val, ok := from.GetCustomParameters(); ok {
p.CustomParameters = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCall) TypeID() uint32 {
return PhoneCallTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCall) TypeName() string {
return "phoneCall"
}
// TypeInfo returns info about TL type.
func (p *PhoneCall) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCall",
ID: PhoneCallTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "P2PAllowed",
SchemaName: "p2p_allowed",
Null: !p.Flags.Has(5),
},
{
Name: "Video",
SchemaName: "video",
Null: !p.Flags.Has(6),
},
{
Name: "ConferenceSupported",
SchemaName: "conference_supported",
Null: !p.Flags.Has(8),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "AccessHash",
SchemaName: "access_hash",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "AdminID",
SchemaName: "admin_id",
},
{
Name: "ParticipantID",
SchemaName: "participant_id",
},
{
Name: "GAOrB",
SchemaName: "g_a_or_b",
},
{
Name: "KeyFingerprint",
SchemaName: "key_fingerprint",
},
{
Name: "Protocol",
SchemaName: "protocol",
},
{
Name: "Connections",
SchemaName: "connections",
},
{
Name: "StartDate",
SchemaName: "start_date",
},
{
Name: "CustomParameters",
SchemaName: "custom_parameters",
Null: !p.Flags.Has(7),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (p *PhoneCall) SetFlags() {
if !(p.P2PAllowed == false) {
p.Flags.Set(5)
}
if !(p.Video == false) {
p.Flags.Set(6)
}
if !(p.ConferenceSupported == false) {
p.Flags.Set(8)
}
if !(p.CustomParameters.Zero()) {
p.Flags.Set(7)
}
}
// Encode implements bin.Encoder.
func (p *PhoneCall) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCall#30535af5 as nil")
}
b.PutID(PhoneCallTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCall) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCall#30535af5 as nil")
}
p.SetFlags()
if err := p.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCall#30535af5: field flags: %w", err)
}
b.PutLong(p.ID)
b.PutLong(p.AccessHash)
b.PutInt(p.Date)
b.PutLong(p.AdminID)
b.PutLong(p.ParticipantID)
b.PutBytes(p.GAOrB)
b.PutLong(p.KeyFingerprint)
if err := p.Protocol.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCall#30535af5: field protocol: %w", err)
}
b.PutVectorHeader(len(p.Connections))
for idx, v := range p.Connections {
if v == nil {
return fmt.Errorf("unable to encode phoneCall#30535af5: field connections element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCall#30535af5: field connections element with index %d: %w", idx, err)
}
}
b.PutInt(p.StartDate)
if p.Flags.Has(7) {
if err := p.CustomParameters.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCall#30535af5: field custom_parameters: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCall) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCall#30535af5 to nil")
}
if err := b.ConsumeID(PhoneCallTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCall) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCall#30535af5 to nil")
}
{
if err := p.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field flags: %w", err)
}
}
p.P2PAllowed = p.Flags.Has(5)
p.Video = p.Flags.Has(6)
p.ConferenceSupported = p.Flags.Has(8)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field id: %w", err)
}
p.ID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field access_hash: %w", err)
}
p.AccessHash = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field date: %w", err)
}
p.Date = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field admin_id: %w", err)
}
p.AdminID = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field participant_id: %w", err)
}
p.ParticipantID = value
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field g_a_or_b: %w", err)
}
p.GAOrB = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field key_fingerprint: %w", err)
}
p.KeyFingerprint = value
}
{
if err := p.Protocol.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field protocol: %w", err)
}
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field connections: %w", err)
}
if headerLen > 0 {
p.Connections = make([]PhoneConnectionClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodePhoneConnection(b)
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field connections: %w", err)
}
p.Connections = append(p.Connections, value)
}
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field start_date: %w", err)
}
p.StartDate = value
}
if p.Flags.Has(7) {
if err := p.CustomParameters.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCall#30535af5: field custom_parameters: %w", err)
}
}
return nil
}
// SetP2PAllowed sets value of P2PAllowed conditional field.
func (p *PhoneCall) SetP2PAllowed(value bool) {
if value {
p.Flags.Set(5)
p.P2PAllowed = true
} else {
p.Flags.Unset(5)
p.P2PAllowed = false
}
}
// GetP2PAllowed returns value of P2PAllowed conditional field.
func (p *PhoneCall) GetP2PAllowed() (value bool) {
if p == nil {
return
}
return p.Flags.Has(5)
}
// SetVideo sets value of Video conditional field.
func (p *PhoneCall) SetVideo(value bool) {
if value {
p.Flags.Set(6)
p.Video = true
} else {
p.Flags.Unset(6)
p.Video = false
}
}
// GetVideo returns value of Video conditional field.
func (p *PhoneCall) GetVideo() (value bool) {
if p == nil {
return
}
return p.Flags.Has(6)
}
// SetConferenceSupported sets value of ConferenceSupported conditional field.
func (p *PhoneCall) SetConferenceSupported(value bool) {
if value {
p.Flags.Set(8)
p.ConferenceSupported = true
} else {
p.Flags.Unset(8)
p.ConferenceSupported = false
}
}
// GetConferenceSupported returns value of ConferenceSupported conditional field.
func (p *PhoneCall) GetConferenceSupported() (value bool) {
if p == nil {
return
}
return p.Flags.Has(8)
}
// GetID returns value of ID field.
func (p *PhoneCall) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// GetAccessHash returns value of AccessHash field.
func (p *PhoneCall) GetAccessHash() (value int64) {
if p == nil {
return
}
return p.AccessHash
}
// GetDate returns value of Date field.
func (p *PhoneCall) GetDate() (value int) {
if p == nil {
return
}
return p.Date
}
// GetAdminID returns value of AdminID field.
func (p *PhoneCall) GetAdminID() (value int64) {
if p == nil {
return
}
return p.AdminID
}
// GetParticipantID returns value of ParticipantID field.
func (p *PhoneCall) GetParticipantID() (value int64) {
if p == nil {
return
}
return p.ParticipantID
}
// GetGAOrB returns value of GAOrB field.
func (p *PhoneCall) GetGAOrB() (value []byte) {
if p == nil {
return
}
return p.GAOrB
}
// GetKeyFingerprint returns value of KeyFingerprint field.
func (p *PhoneCall) GetKeyFingerprint() (value int64) {
if p == nil {
return
}
return p.KeyFingerprint
}
// GetProtocol returns value of Protocol field.
func (p *PhoneCall) GetProtocol() (value PhoneCallProtocol) {
if p == nil {
return
}
return p.Protocol
}
// GetConnections returns value of Connections field.
func (p *PhoneCall) GetConnections() (value []PhoneConnectionClass) {
if p == nil {
return
}
return p.Connections
}
// GetStartDate returns value of StartDate field.
func (p *PhoneCall) GetStartDate() (value int) {
if p == nil {
return
}
return p.StartDate
}
// SetCustomParameters sets value of CustomParameters conditional field.
func (p *PhoneCall) SetCustomParameters(value DataJSON) {
p.Flags.Set(7)
p.CustomParameters = value
}
// GetCustomParameters returns value of CustomParameters conditional field and
// boolean which is true if field was set.
func (p *PhoneCall) GetCustomParameters() (value DataJSON, ok bool) {
if p == nil {
return
}
if !p.Flags.Has(7) {
return value, false
}
return p.CustomParameters, true
}
// MapConnections returns field Connections wrapped in PhoneConnectionClassArray helper.
func (p *PhoneCall) MapConnections() (value PhoneConnectionClassArray) {
return PhoneConnectionClassArray(p.Connections)
}
// PhoneCallDiscarded represents TL type `phoneCallDiscarded#50ca4de1`.
// Indicates a discarded phone call
//
// See https://core.telegram.org/constructor/phoneCallDiscarded for reference.
type PhoneCallDiscarded struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether the server required the user to rate¹ the call
//
// Links:
// 1) https://core.telegram.org/method/phone.setCallRating
NeedRating bool
// Whether the server required the client to send¹ the libtgvoip call debug data
//
// Links:
// 1) https://core.telegram.org/method/phone.saveCallDebug
NeedDebug bool
// Whether the call was a video call
Video bool
// Call ID
ID int64
// Why was the phone call discarded
//
// Use SetReason and GetReason helpers.
Reason PhoneCallDiscardReasonClass
// Duration of the phone call in seconds
//
// Use SetDuration and GetDuration helpers.
Duration int
}
// PhoneCallDiscardedTypeID is TL type id of PhoneCallDiscarded.
const PhoneCallDiscardedTypeID = 0x50ca4de1
// construct implements constructor of PhoneCallClass.
func (p PhoneCallDiscarded) construct() PhoneCallClass { return &p }
// Ensuring interfaces in compile-time for PhoneCallDiscarded.
var (
_ bin.Encoder = &PhoneCallDiscarded{}
_ bin.Decoder = &PhoneCallDiscarded{}
_ bin.BareEncoder = &PhoneCallDiscarded{}
_ bin.BareDecoder = &PhoneCallDiscarded{}
_ PhoneCallClass = &PhoneCallDiscarded{}
)
func (p *PhoneCallDiscarded) Zero() bool {
if p == nil {
return true
}
if !(p.Flags.Zero()) {
return false
}
if !(p.NeedRating == false) {
return false
}
if !(p.NeedDebug == false) {
return false
}
if !(p.Video == false) {
return false
}
if !(p.ID == 0) {
return false
}
if !(p.Reason == nil) {
return false
}
if !(p.Duration == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhoneCallDiscarded) String() string {
if p == nil {
return "PhoneCallDiscarded(nil)"
}
type Alias PhoneCallDiscarded
return fmt.Sprintf("PhoneCallDiscarded%+v", Alias(*p))
}
// FillFrom fills PhoneCallDiscarded from given interface.
func (p *PhoneCallDiscarded) FillFrom(from interface {
GetNeedRating() (value bool)
GetNeedDebug() (value bool)
GetVideo() (value bool)
GetID() (value int64)
GetReason() (value PhoneCallDiscardReasonClass, ok bool)
GetDuration() (value int, ok bool)
}) {
p.NeedRating = from.GetNeedRating()
p.NeedDebug = from.GetNeedDebug()
p.Video = from.GetVideo()
p.ID = from.GetID()
if val, ok := from.GetReason(); ok {
p.Reason = val
}
if val, ok := from.GetDuration(); ok {
p.Duration = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhoneCallDiscarded) TypeID() uint32 {
return PhoneCallDiscardedTypeID
}
// TypeName returns name of type in TL schema.
func (*PhoneCallDiscarded) TypeName() string {
return "phoneCallDiscarded"
}
// TypeInfo returns info about TL type.
func (p *PhoneCallDiscarded) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "phoneCallDiscarded",
ID: PhoneCallDiscardedTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "NeedRating",
SchemaName: "need_rating",
Null: !p.Flags.Has(2),
},
{
Name: "NeedDebug",
SchemaName: "need_debug",
Null: !p.Flags.Has(3),
},
{
Name: "Video",
SchemaName: "video",
Null: !p.Flags.Has(6),
},
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Reason",
SchemaName: "reason",
Null: !p.Flags.Has(0),
},
{
Name: "Duration",
SchemaName: "duration",
Null: !p.Flags.Has(1),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (p *PhoneCallDiscarded) SetFlags() {
if !(p.NeedRating == false) {
p.Flags.Set(2)
}
if !(p.NeedDebug == false) {
p.Flags.Set(3)
}
if !(p.Video == false) {
p.Flags.Set(6)
}
if !(p.Reason == nil) {
p.Flags.Set(0)
}
if !(p.Duration == 0) {
p.Flags.Set(1)
}
}
// Encode implements bin.Encoder.
func (p *PhoneCallDiscarded) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallDiscarded#50ca4de1 as nil")
}
b.PutID(PhoneCallDiscardedTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhoneCallDiscarded) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode phoneCallDiscarded#50ca4de1 as nil")
}
p.SetFlags()
if err := p.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field flags: %w", err)
}
b.PutLong(p.ID)
if p.Flags.Has(0) {
if p.Reason == nil {
return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field reason is nil")
}
if err := p.Reason.Encode(b); err != nil {
return fmt.Errorf("unable to encode phoneCallDiscarded#50ca4de1: field reason: %w", err)
}
}
if p.Flags.Has(1) {
b.PutInt(p.Duration)
}
return nil
}
// Decode implements bin.Decoder.
func (p *PhoneCallDiscarded) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallDiscarded#50ca4de1 to nil")
}
if err := b.ConsumeID(PhoneCallDiscardedTypeID); err != nil {
return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhoneCallDiscarded) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode phoneCallDiscarded#50ca4de1 to nil")
}
{
if err := p.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field flags: %w", err)
}
}
p.NeedRating = p.Flags.Has(2)
p.NeedDebug = p.Flags.Has(3)
p.Video = p.Flags.Has(6)
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field id: %w", err)
}
p.ID = value
}
if p.Flags.Has(0) {
value, err := DecodePhoneCallDiscardReason(b)
if err != nil {
return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field reason: %w", err)
}
p.Reason = value
}
if p.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode phoneCallDiscarded#50ca4de1: field duration: %w", err)
}
p.Duration = value
}
return nil
}
// SetNeedRating sets value of NeedRating conditional field.
func (p *PhoneCallDiscarded) SetNeedRating(value bool) {
if value {
p.Flags.Set(2)
p.NeedRating = true
} else {
p.Flags.Unset(2)
p.NeedRating = false
}
}
// GetNeedRating returns value of NeedRating conditional field.
func (p *PhoneCallDiscarded) GetNeedRating() (value bool) {
if p == nil {
return
}
return p.Flags.Has(2)
}
// SetNeedDebug sets value of NeedDebug conditional field.
func (p *PhoneCallDiscarded) SetNeedDebug(value bool) {
if value {
p.Flags.Set(3)
p.NeedDebug = true
} else {
p.Flags.Unset(3)
p.NeedDebug = false
}
}
// GetNeedDebug returns value of NeedDebug conditional field.
func (p *PhoneCallDiscarded) GetNeedDebug() (value bool) {
if p == nil {
return
}
return p.Flags.Has(3)
}
// SetVideo sets value of Video conditional field.
func (p *PhoneCallDiscarded) SetVideo(value bool) {
if value {
p.Flags.Set(6)
p.Video = true
} else {
p.Flags.Unset(6)
p.Video = false
}
}
// GetVideo returns value of Video conditional field.
func (p *PhoneCallDiscarded) GetVideo() (value bool) {
if p == nil {
return
}
return p.Flags.Has(6)
}
// GetID returns value of ID field.
func (p *PhoneCallDiscarded) GetID() (value int64) {
if p == nil {
return
}
return p.ID
}
// SetReason sets value of Reason conditional field.
func (p *PhoneCallDiscarded) SetReason(value PhoneCallDiscardReasonClass) {
p.Flags.Set(0)
p.Reason = value
}
// GetReason returns value of Reason conditional field and
// boolean which is true if field was set.
func (p *PhoneCallDiscarded) GetReason() (value PhoneCallDiscardReasonClass, ok bool) {
if p == nil {
return
}
if !p.Flags.Has(0) {
return value, false
}
return p.Reason, true
}
// SetDuration sets value of Duration conditional field.
func (p *PhoneCallDiscarded) SetDuration(value int) {
p.Flags.Set(1)
p.Duration = value
}
// GetDuration returns value of Duration conditional field and
// boolean which is true if field was set.
func (p *PhoneCallDiscarded) GetDuration() (value int, ok bool) {
if p == nil {
return
}
if !p.Flags.Has(1) {
return value, false
}
return p.Duration, true
}
// PhoneCallClassName is schema name of PhoneCallClass.
const PhoneCallClassName = "PhoneCall"
// PhoneCallClass represents PhoneCall generic type.
//
// See https://core.telegram.org/type/PhoneCall for reference.
//
// Example:
//
// g, err := tg.DecodePhoneCall(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.PhoneCallEmpty: // phoneCallEmpty#5366c915
// case *tg.PhoneCallWaiting: // phoneCallWaiting#c5226f17
// case *tg.PhoneCallRequested: // phoneCallRequested#14b0ed0c
// case *tg.PhoneCallAccepted: // phoneCallAccepted#3660c311
// case *tg.PhoneCall: // phoneCall#30535af5
// case *tg.PhoneCallDiscarded: // phoneCallDiscarded#50ca4de1
// default: panic(v)
// }
type PhoneCallClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() PhoneCallClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
// Call ID
GetID() (value int64)
// AsNotEmpty tries to map PhoneCallClass to NotEmptyPhoneCall.
AsNotEmpty() (NotEmptyPhoneCall, bool)
}
// AsInput tries to map PhoneCall to InputPhoneCall.
func (p *PhoneCall) AsInput() *InputPhoneCall {
value := new(InputPhoneCall)
value.ID = p.GetID()
value.AccessHash = p.GetAccessHash()
return value
}
// NotEmptyPhoneCall represents NotEmpty subset of PhoneCallClass.
type NotEmptyPhoneCall interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() PhoneCallClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
// Is this a video call
GetVideo() (value bool)
// Call ID
GetID() (value int64)
}
// AsNotEmpty tries to map PhoneCallEmpty to NotEmptyPhoneCall.
func (p *PhoneCallEmpty) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// AsNotEmpty tries to map PhoneCallWaiting to NotEmptyPhoneCall.
func (p *PhoneCallWaiting) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// AsNotEmpty tries to map PhoneCallRequested to NotEmptyPhoneCall.
func (p *PhoneCallRequested) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// AsNotEmpty tries to map PhoneCallAccepted to NotEmptyPhoneCall.
func (p *PhoneCallAccepted) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// AsNotEmpty tries to map PhoneCall to NotEmptyPhoneCall.
func (p *PhoneCall) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// AsNotEmpty tries to map PhoneCallDiscarded to NotEmptyPhoneCall.
func (p *PhoneCallDiscarded) AsNotEmpty() (NotEmptyPhoneCall, bool) {
value, ok := (PhoneCallClass(p)).(NotEmptyPhoneCall)
return value, ok
}
// DecodePhoneCall implements binary de-serialization for PhoneCallClass.
func DecodePhoneCall(buf *bin.Buffer) (PhoneCallClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case PhoneCallEmptyTypeID:
// Decoding phoneCallEmpty#5366c915.
v := PhoneCallEmpty{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
case PhoneCallWaitingTypeID:
// Decoding phoneCallWaiting#c5226f17.
v := PhoneCallWaiting{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
case PhoneCallRequestedTypeID:
// Decoding phoneCallRequested#14b0ed0c.
v := PhoneCallRequested{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
case PhoneCallAcceptedTypeID:
// Decoding phoneCallAccepted#3660c311.
v := PhoneCallAccepted{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
case PhoneCallTypeID:
// Decoding phoneCall#30535af5.
v := PhoneCall{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
case PhoneCallDiscardedTypeID:
// Decoding phoneCallDiscarded#50ca4de1.
v := PhoneCallDiscarded{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode PhoneCallClass: %w", bin.NewUnexpectedID(id))
}
}
// PhoneCall boxes the PhoneCallClass providing a helper.
type PhoneCallBox struct {
PhoneCall PhoneCallClass
}
// Decode implements bin.Decoder for PhoneCallBox.
func (b *PhoneCallBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode PhoneCallBox to nil")
}
v, err := DecodePhoneCall(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.PhoneCall = v
return nil
}
// Encode implements bin.Encode for PhoneCallBox.
func (b *PhoneCallBox) Encode(buf *bin.Buffer) error {
if b == nil || b.PhoneCall == nil {
return fmt.Errorf("unable to encode PhoneCallClass as nil")
}
return b.PhoneCall.Encode(buf)
}