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,196 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ContactsAcceptContactRequest represents TL type `contacts.acceptContact#f831a20f`.
|
||||
// If the add contact action bar is active¹, add that user as contact
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/action-bar#add-contact
|
||||
//
|
||||
// See https://core.telegram.org/method/contacts.acceptContact for reference.
|
||||
type ContactsAcceptContactRequest struct {
|
||||
// The user to add as contact
|
||||
ID InputUserClass
|
||||
}
|
||||
|
||||
// ContactsAcceptContactRequestTypeID is TL type id of ContactsAcceptContactRequest.
|
||||
const ContactsAcceptContactRequestTypeID = 0xf831a20f
|
||||
|
||||
// Ensuring interfaces in compile-time for ContactsAcceptContactRequest.
|
||||
var (
|
||||
_ bin.Encoder = &ContactsAcceptContactRequest{}
|
||||
_ bin.Decoder = &ContactsAcceptContactRequest{}
|
||||
_ bin.BareEncoder = &ContactsAcceptContactRequest{}
|
||||
_ bin.BareDecoder = &ContactsAcceptContactRequest{}
|
||||
)
|
||||
|
||||
func (a *ContactsAcceptContactRequest) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.ID == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *ContactsAcceptContactRequest) String() string {
|
||||
if a == nil {
|
||||
return "ContactsAcceptContactRequest(nil)"
|
||||
}
|
||||
type Alias ContactsAcceptContactRequest
|
||||
return fmt.Sprintf("ContactsAcceptContactRequest%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// FillFrom fills ContactsAcceptContactRequest from given interface.
|
||||
func (a *ContactsAcceptContactRequest) FillFrom(from interface {
|
||||
GetID() (value InputUserClass)
|
||||
}) {
|
||||
a.ID = from.GetID()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ContactsAcceptContactRequest) TypeID() uint32 {
|
||||
return ContactsAcceptContactRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ContactsAcceptContactRequest) TypeName() string {
|
||||
return "contacts.acceptContact"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *ContactsAcceptContactRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "contacts.acceptContact",
|
||||
ID: ContactsAcceptContactRequestTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *ContactsAcceptContactRequest) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode contacts.acceptContact#f831a20f as nil")
|
||||
}
|
||||
b.PutID(ContactsAcceptContactRequestTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *ContactsAcceptContactRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode contacts.acceptContact#f831a20f as nil")
|
||||
}
|
||||
if a.ID == nil {
|
||||
return fmt.Errorf("unable to encode contacts.acceptContact#f831a20f: field id is nil")
|
||||
}
|
||||
if err := a.ID.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode contacts.acceptContact#f831a20f: field id: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *ContactsAcceptContactRequest) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode contacts.acceptContact#f831a20f to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ContactsAcceptContactRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode contacts.acceptContact#f831a20f: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *ContactsAcceptContactRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode contacts.acceptContact#f831a20f to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputUser(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode contacts.acceptContact#f831a20f: field id: %w", err)
|
||||
}
|
||||
a.ID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (a *ContactsAcceptContactRequest) GetID() (value InputUserClass) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.ID
|
||||
}
|
||||
|
||||
// ContactsAcceptContact invokes method contacts.acceptContact#f831a20f returning error if any.
|
||||
// If the add contact action bar is active¹, add that user as contact
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/action-bar#add-contact
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 CONTACT_ADD_MISSING: Contact to add is missing.
|
||||
// 400 CONTACT_ID_INVALID: The provided contact ID is invalid.
|
||||
// 400 CONTACT_REQ_MISSING: Missing contact request.
|
||||
// 400 MSG_ID_INVALID: Invalid message ID provided.
|
||||
//
|
||||
// See https://core.telegram.org/method/contacts.acceptContact for reference.
|
||||
func (c *Client) ContactsAcceptContact(ctx context.Context, id InputUserClass) (UpdatesClass, error) {
|
||||
var result UpdatesBox
|
||||
|
||||
request := &ContactsAcceptContactRequest{
|
||||
ID: id,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Updates, nil
|
||||
}
|
||||
Reference in New Issue
Block a user