7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
193 lines
4.9 KiB
Go
193 lines
4.9 KiB
Go
// 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{}
|
|
)
|
|
|
|
// ContactsDeleteByPhonesRequest represents TL type `contacts.deleteByPhones#1013fd9e`.
|
|
// Delete contacts by phone number
|
|
//
|
|
// See https://core.telegram.org/method/contacts.deleteByPhones for reference.
|
|
type ContactsDeleteByPhonesRequest struct {
|
|
// Phone numbers
|
|
Phones []string
|
|
}
|
|
|
|
// ContactsDeleteByPhonesRequestTypeID is TL type id of ContactsDeleteByPhonesRequest.
|
|
const ContactsDeleteByPhonesRequestTypeID = 0x1013fd9e
|
|
|
|
// Ensuring interfaces in compile-time for ContactsDeleteByPhonesRequest.
|
|
var (
|
|
_ bin.Encoder = &ContactsDeleteByPhonesRequest{}
|
|
_ bin.Decoder = &ContactsDeleteByPhonesRequest{}
|
|
_ bin.BareEncoder = &ContactsDeleteByPhonesRequest{}
|
|
_ bin.BareDecoder = &ContactsDeleteByPhonesRequest{}
|
|
)
|
|
|
|
func (d *ContactsDeleteByPhonesRequest) Zero() bool {
|
|
if d == nil {
|
|
return true
|
|
}
|
|
if !(d.Phones == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (d *ContactsDeleteByPhonesRequest) String() string {
|
|
if d == nil {
|
|
return "ContactsDeleteByPhonesRequest(nil)"
|
|
}
|
|
type Alias ContactsDeleteByPhonesRequest
|
|
return fmt.Sprintf("ContactsDeleteByPhonesRequest%+v", Alias(*d))
|
|
}
|
|
|
|
// FillFrom fills ContactsDeleteByPhonesRequest from given interface.
|
|
func (d *ContactsDeleteByPhonesRequest) FillFrom(from interface {
|
|
GetPhones() (value []string)
|
|
}) {
|
|
d.Phones = from.GetPhones()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ContactsDeleteByPhonesRequest) TypeID() uint32 {
|
|
return ContactsDeleteByPhonesRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ContactsDeleteByPhonesRequest) TypeName() string {
|
|
return "contacts.deleteByPhones"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (d *ContactsDeleteByPhonesRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "contacts.deleteByPhones",
|
|
ID: ContactsDeleteByPhonesRequestTypeID,
|
|
}
|
|
if d == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Phones",
|
|
SchemaName: "phones",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (d *ContactsDeleteByPhonesRequest) Encode(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't encode contacts.deleteByPhones#1013fd9e as nil")
|
|
}
|
|
b.PutID(ContactsDeleteByPhonesRequestTypeID)
|
|
return d.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (d *ContactsDeleteByPhonesRequest) EncodeBare(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't encode contacts.deleteByPhones#1013fd9e as nil")
|
|
}
|
|
b.PutVectorHeader(len(d.Phones))
|
|
for _, v := range d.Phones {
|
|
b.PutString(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (d *ContactsDeleteByPhonesRequest) Decode(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't decode contacts.deleteByPhones#1013fd9e to nil")
|
|
}
|
|
if err := b.ConsumeID(ContactsDeleteByPhonesRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode contacts.deleteByPhones#1013fd9e: %w", err)
|
|
}
|
|
return d.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (d *ContactsDeleteByPhonesRequest) DecodeBare(b *bin.Buffer) error {
|
|
if d == nil {
|
|
return fmt.Errorf("can't decode contacts.deleteByPhones#1013fd9e to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode contacts.deleteByPhones#1013fd9e: field phones: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
d.Phones = make([]string, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode contacts.deleteByPhones#1013fd9e: field phones: %w", err)
|
|
}
|
|
d.Phones = append(d.Phones, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPhones returns value of Phones field.
|
|
func (d *ContactsDeleteByPhonesRequest) GetPhones() (value []string) {
|
|
if d == nil {
|
|
return
|
|
}
|
|
return d.Phones
|
|
}
|
|
|
|
// ContactsDeleteByPhones invokes method contacts.deleteByPhones#1013fd9e returning error if any.
|
|
// Delete contacts by phone number
|
|
//
|
|
// See https://core.telegram.org/method/contacts.deleteByPhones for reference.
|
|
func (c *Client) ContactsDeleteByPhones(ctx context.Context, phones []string) (bool, error) {
|
|
var result BoolBox
|
|
|
|
request := &ContactsDeleteByPhonesRequest{
|
|
Phones: phones,
|
|
}
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return false, err
|
|
}
|
|
_, ok := result.Bool.(*BoolTrue)
|
|
return ok, nil
|
|
}
|