move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ContactsGetContactIDsRequest represents TL type `contacts.getContactIDs#7adc669d`.
|
||||
// Get the telegram IDs of all contacts.
|
||||
// Returns an array of Telegram user IDs for all contacts (0 if a contact does not have
|
||||
// an associated Telegram account or have hidden their account using privacy settings).
|
||||
//
|
||||
// See https://core.telegram.org/method/contacts.getContactIDs for reference.
|
||||
type ContactsGetContactIDsRequest struct {
|
||||
// Hash used for caching, for more info click here¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/offsets#hash-generation
|
||||
Hash int64
|
||||
}
|
||||
|
||||
// ContactsGetContactIDsRequestTypeID is TL type id of ContactsGetContactIDsRequest.
|
||||
const ContactsGetContactIDsRequestTypeID = 0x7adc669d
|
||||
|
||||
// Ensuring interfaces in compile-time for ContactsGetContactIDsRequest.
|
||||
var (
|
||||
_ bin.Encoder = &ContactsGetContactIDsRequest{}
|
||||
_ bin.Decoder = &ContactsGetContactIDsRequest{}
|
||||
_ bin.BareEncoder = &ContactsGetContactIDsRequest{}
|
||||
_ bin.BareDecoder = &ContactsGetContactIDsRequest{}
|
||||
)
|
||||
|
||||
func (g *ContactsGetContactIDsRequest) Zero() bool {
|
||||
if g == nil {
|
||||
return true
|
||||
}
|
||||
if !(g.Hash == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (g *ContactsGetContactIDsRequest) String() string {
|
||||
if g == nil {
|
||||
return "ContactsGetContactIDsRequest(nil)"
|
||||
}
|
||||
type Alias ContactsGetContactIDsRequest
|
||||
return fmt.Sprintf("ContactsGetContactIDsRequest%+v", Alias(*g))
|
||||
}
|
||||
|
||||
// FillFrom fills ContactsGetContactIDsRequest from given interface.
|
||||
func (g *ContactsGetContactIDsRequest) FillFrom(from interface {
|
||||
GetHash() (value int64)
|
||||
}) {
|
||||
g.Hash = from.GetHash()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ContactsGetContactIDsRequest) TypeID() uint32 {
|
||||
return ContactsGetContactIDsRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ContactsGetContactIDsRequest) TypeName() string {
|
||||
return "contacts.getContactIDs"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (g *ContactsGetContactIDsRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "contacts.getContactIDs",
|
||||
ID: ContactsGetContactIDsRequestTypeID,
|
||||
}
|
||||
if g == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Hash",
|
||||
SchemaName: "hash",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (g *ContactsGetContactIDsRequest) Encode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode contacts.getContactIDs#7adc669d as nil")
|
||||
}
|
||||
b.PutID(ContactsGetContactIDsRequestTypeID)
|
||||
return g.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (g *ContactsGetContactIDsRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode contacts.getContactIDs#7adc669d as nil")
|
||||
}
|
||||
b.PutLong(g.Hash)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (g *ContactsGetContactIDsRequest) Decode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode contacts.getContactIDs#7adc669d to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ContactsGetContactIDsRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode contacts.getContactIDs#7adc669d: %w", err)
|
||||
}
|
||||
return g.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (g *ContactsGetContactIDsRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode contacts.getContactIDs#7adc669d to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode contacts.getContactIDs#7adc669d: field hash: %w", err)
|
||||
}
|
||||
g.Hash = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetHash returns value of Hash field.
|
||||
func (g *ContactsGetContactIDsRequest) GetHash() (value int64) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.Hash
|
||||
}
|
||||
|
||||
// ContactsGetContactIDs invokes method contacts.getContactIDs#7adc669d returning error if any.
|
||||
// Get the telegram IDs of all contacts.
|
||||
// Returns an array of Telegram user IDs for all contacts (0 if a contact does not have
|
||||
// an associated Telegram account or have hidden their account using privacy settings).
|
||||
//
|
||||
// See https://core.telegram.org/method/contacts.getContactIDs for reference.
|
||||
func (c *Client) ContactsGetContactIDs(ctx context.Context, hash int64) ([]int, error) {
|
||||
var result IntVector
|
||||
|
||||
request := &ContactsGetContactIDsRequest{
|
||||
Hash: hash,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []int(result.Elems), nil
|
||||
}
|
||||
Reference in New Issue
Block a user