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
331 lines
8.1 KiB
Go
331 lines
8.1 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tdapi
|
|
|
|
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{}
|
|
)
|
|
|
|
// AccountInfo represents TL type `accountInfo#6b7f1d67`.
|
|
type AccountInfo struct {
|
|
// Month when the user was registered in Telegram; 0-12; may be 0 if unknown
|
|
RegistrationMonth int32
|
|
// Year when the user was registered in Telegram; 0-9999; may be 0 if unknown
|
|
RegistrationYear int32
|
|
// A two-letter ISO 3166-1 alpha-2 country code based on the phone number of the user;
|
|
// may be empty if unknown
|
|
PhoneNumberCountryCode string
|
|
// Point in time (Unix timestamp) when the user changed name last time; 0 if unknown
|
|
LastNameChangeDate int32
|
|
// Point in time (Unix timestamp) when the user changed photo last time; 0 if unknown
|
|
LastPhotoChangeDate int32
|
|
}
|
|
|
|
// AccountInfoTypeID is TL type id of AccountInfo.
|
|
const AccountInfoTypeID = 0x6b7f1d67
|
|
|
|
// Ensuring interfaces in compile-time for AccountInfo.
|
|
var (
|
|
_ bin.Encoder = &AccountInfo{}
|
|
_ bin.Decoder = &AccountInfo{}
|
|
_ bin.BareEncoder = &AccountInfo{}
|
|
_ bin.BareDecoder = &AccountInfo{}
|
|
)
|
|
|
|
func (a *AccountInfo) Zero() bool {
|
|
if a == nil {
|
|
return true
|
|
}
|
|
if !(a.RegistrationMonth == 0) {
|
|
return false
|
|
}
|
|
if !(a.RegistrationYear == 0) {
|
|
return false
|
|
}
|
|
if !(a.PhoneNumberCountryCode == "") {
|
|
return false
|
|
}
|
|
if !(a.LastNameChangeDate == 0) {
|
|
return false
|
|
}
|
|
if !(a.LastPhotoChangeDate == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (a *AccountInfo) String() string {
|
|
if a == nil {
|
|
return "AccountInfo(nil)"
|
|
}
|
|
type Alias AccountInfo
|
|
return fmt.Sprintf("AccountInfo%+v", Alias(*a))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*AccountInfo) TypeID() uint32 {
|
|
return AccountInfoTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*AccountInfo) TypeName() string {
|
|
return "accountInfo"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (a *AccountInfo) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "accountInfo",
|
|
ID: AccountInfoTypeID,
|
|
}
|
|
if a == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "RegistrationMonth",
|
|
SchemaName: "registration_month",
|
|
},
|
|
{
|
|
Name: "RegistrationYear",
|
|
SchemaName: "registration_year",
|
|
},
|
|
{
|
|
Name: "PhoneNumberCountryCode",
|
|
SchemaName: "phone_number_country_code",
|
|
},
|
|
{
|
|
Name: "LastNameChangeDate",
|
|
SchemaName: "last_name_change_date",
|
|
},
|
|
{
|
|
Name: "LastPhotoChangeDate",
|
|
SchemaName: "last_photo_change_date",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (a *AccountInfo) Encode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode accountInfo#6b7f1d67 as nil")
|
|
}
|
|
b.PutID(AccountInfoTypeID)
|
|
return a.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (a *AccountInfo) EncodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode accountInfo#6b7f1d67 as nil")
|
|
}
|
|
b.PutInt32(a.RegistrationMonth)
|
|
b.PutInt32(a.RegistrationYear)
|
|
b.PutString(a.PhoneNumberCountryCode)
|
|
b.PutInt32(a.LastNameChangeDate)
|
|
b.PutInt32(a.LastPhotoChangeDate)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (a *AccountInfo) Decode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode accountInfo#6b7f1d67 to nil")
|
|
}
|
|
if err := b.ConsumeID(AccountInfoTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: %w", err)
|
|
}
|
|
return a.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (a *AccountInfo) DecodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode accountInfo#6b7f1d67 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field registration_month: %w", err)
|
|
}
|
|
a.RegistrationMonth = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field registration_year: %w", err)
|
|
}
|
|
a.RegistrationYear = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field phone_number_country_code: %w", err)
|
|
}
|
|
a.PhoneNumberCountryCode = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field last_name_change_date: %w", err)
|
|
}
|
|
a.LastNameChangeDate = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field last_photo_change_date: %w", err)
|
|
}
|
|
a.LastPhotoChangeDate = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (a *AccountInfo) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode accountInfo#6b7f1d67 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("accountInfo")
|
|
b.Comma()
|
|
b.FieldStart("registration_month")
|
|
b.PutInt32(a.RegistrationMonth)
|
|
b.Comma()
|
|
b.FieldStart("registration_year")
|
|
b.PutInt32(a.RegistrationYear)
|
|
b.Comma()
|
|
b.FieldStart("phone_number_country_code")
|
|
b.PutString(a.PhoneNumberCountryCode)
|
|
b.Comma()
|
|
b.FieldStart("last_name_change_date")
|
|
b.PutInt32(a.LastNameChangeDate)
|
|
b.Comma()
|
|
b.FieldStart("last_photo_change_date")
|
|
b.PutInt32(a.LastPhotoChangeDate)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (a *AccountInfo) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode accountInfo#6b7f1d67 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("accountInfo"); err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: %w", err)
|
|
}
|
|
case "registration_month":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field registration_month: %w", err)
|
|
}
|
|
a.RegistrationMonth = value
|
|
case "registration_year":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field registration_year: %w", err)
|
|
}
|
|
a.RegistrationYear = value
|
|
case "phone_number_country_code":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field phone_number_country_code: %w", err)
|
|
}
|
|
a.PhoneNumberCountryCode = value
|
|
case "last_name_change_date":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field last_name_change_date: %w", err)
|
|
}
|
|
a.LastNameChangeDate = value
|
|
case "last_photo_change_date":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode accountInfo#6b7f1d67: field last_photo_change_date: %w", err)
|
|
}
|
|
a.LastPhotoChangeDate = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetRegistrationMonth returns value of RegistrationMonth field.
|
|
func (a *AccountInfo) GetRegistrationMonth() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.RegistrationMonth
|
|
}
|
|
|
|
// GetRegistrationYear returns value of RegistrationYear field.
|
|
func (a *AccountInfo) GetRegistrationYear() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.RegistrationYear
|
|
}
|
|
|
|
// GetPhoneNumberCountryCode returns value of PhoneNumberCountryCode field.
|
|
func (a *AccountInfo) GetPhoneNumberCountryCode() (value string) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.PhoneNumberCountryCode
|
|
}
|
|
|
|
// GetLastNameChangeDate returns value of LastNameChangeDate field.
|
|
func (a *AccountInfo) GetLastNameChangeDate() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.LastNameChangeDate
|
|
}
|
|
|
|
// GetLastPhotoChangeDate returns value of LastPhotoChangeDate field.
|
|
func (a *AccountInfo) GetLastPhotoChangeDate() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.LastPhotoChangeDate
|
|
}
|