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,243 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// SavedPhoneContact represents TL type `savedPhoneContact#1142bd56`.
|
||||
// Saved contact
|
||||
//
|
||||
// See https://core.telegram.org/constructor/savedPhoneContact for reference.
|
||||
type SavedPhoneContact struct {
|
||||
// Phone number
|
||||
Phone string
|
||||
// First name
|
||||
FirstName string
|
||||
// Last name
|
||||
LastName string
|
||||
// Date added
|
||||
Date int
|
||||
}
|
||||
|
||||
// SavedPhoneContactTypeID is TL type id of SavedPhoneContact.
|
||||
const SavedPhoneContactTypeID = 0x1142bd56
|
||||
|
||||
// Ensuring interfaces in compile-time for SavedPhoneContact.
|
||||
var (
|
||||
_ bin.Encoder = &SavedPhoneContact{}
|
||||
_ bin.Decoder = &SavedPhoneContact{}
|
||||
_ bin.BareEncoder = &SavedPhoneContact{}
|
||||
_ bin.BareDecoder = &SavedPhoneContact{}
|
||||
)
|
||||
|
||||
func (s *SavedPhoneContact) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.Phone == "") {
|
||||
return false
|
||||
}
|
||||
if !(s.FirstName == "") {
|
||||
return false
|
||||
}
|
||||
if !(s.LastName == "") {
|
||||
return false
|
||||
}
|
||||
if !(s.Date == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *SavedPhoneContact) String() string {
|
||||
if s == nil {
|
||||
return "SavedPhoneContact(nil)"
|
||||
}
|
||||
type Alias SavedPhoneContact
|
||||
return fmt.Sprintf("SavedPhoneContact%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// FillFrom fills SavedPhoneContact from given interface.
|
||||
func (s *SavedPhoneContact) FillFrom(from interface {
|
||||
GetPhone() (value string)
|
||||
GetFirstName() (value string)
|
||||
GetLastName() (value string)
|
||||
GetDate() (value int)
|
||||
}) {
|
||||
s.Phone = from.GetPhone()
|
||||
s.FirstName = from.GetFirstName()
|
||||
s.LastName = from.GetLastName()
|
||||
s.Date = from.GetDate()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*SavedPhoneContact) TypeID() uint32 {
|
||||
return SavedPhoneContactTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*SavedPhoneContact) TypeName() string {
|
||||
return "savedPhoneContact"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *SavedPhoneContact) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "savedPhoneContact",
|
||||
ID: SavedPhoneContactTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Phone",
|
||||
SchemaName: "phone",
|
||||
},
|
||||
{
|
||||
Name: "FirstName",
|
||||
SchemaName: "first_name",
|
||||
},
|
||||
{
|
||||
Name: "LastName",
|
||||
SchemaName: "last_name",
|
||||
},
|
||||
{
|
||||
Name: "Date",
|
||||
SchemaName: "date",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *SavedPhoneContact) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode savedPhoneContact#1142bd56 as nil")
|
||||
}
|
||||
b.PutID(SavedPhoneContactTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *SavedPhoneContact) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode savedPhoneContact#1142bd56 as nil")
|
||||
}
|
||||
b.PutString(s.Phone)
|
||||
b.PutString(s.FirstName)
|
||||
b.PutString(s.LastName)
|
||||
b.PutInt(s.Date)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *SavedPhoneContact) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode savedPhoneContact#1142bd56 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(SavedPhoneContactTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *SavedPhoneContact) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode savedPhoneContact#1142bd56 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field phone: %w", err)
|
||||
}
|
||||
s.Phone = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field first_name: %w", err)
|
||||
}
|
||||
s.FirstName = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field last_name: %w", err)
|
||||
}
|
||||
s.LastName = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode savedPhoneContact#1142bd56: field date: %w", err)
|
||||
}
|
||||
s.Date = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPhone returns value of Phone field.
|
||||
func (s *SavedPhoneContact) GetPhone() (value string) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Phone
|
||||
}
|
||||
|
||||
// GetFirstName returns value of FirstName field.
|
||||
func (s *SavedPhoneContact) GetFirstName() (value string) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.FirstName
|
||||
}
|
||||
|
||||
// GetLastName returns value of LastName field.
|
||||
func (s *SavedPhoneContact) GetLastName() (value string) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.LastName
|
||||
}
|
||||
|
||||
// GetDate returns value of Date field.
|
||||
func (s *SavedPhoneContact) GetDate() (value int) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Date
|
||||
}
|
||||
Reference in New Issue
Block a user