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
1194 lines
31 KiB
Go
1194 lines
31 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{}
|
|
)
|
|
|
|
// UserStatusEmpty represents TL type `userStatusEmpty#9d05049`.
|
|
type UserStatusEmpty struct {
|
|
}
|
|
|
|
// UserStatusEmptyTypeID is TL type id of UserStatusEmpty.
|
|
const UserStatusEmptyTypeID = 0x9d05049
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusEmpty) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusEmpty.
|
|
var (
|
|
_ bin.Encoder = &UserStatusEmpty{}
|
|
_ bin.Decoder = &UserStatusEmpty{}
|
|
_ bin.BareEncoder = &UserStatusEmpty{}
|
|
_ bin.BareDecoder = &UserStatusEmpty{}
|
|
|
|
_ UserStatusClass = &UserStatusEmpty{}
|
|
)
|
|
|
|
func (u *UserStatusEmpty) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusEmpty) String() string {
|
|
if u == nil {
|
|
return "UserStatusEmpty(nil)"
|
|
}
|
|
type Alias UserStatusEmpty
|
|
return fmt.Sprintf("UserStatusEmpty%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusEmpty) TypeID() uint32 {
|
|
return UserStatusEmptyTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusEmpty) TypeName() string {
|
|
return "userStatusEmpty"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusEmpty) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusEmpty",
|
|
ID: UserStatusEmptyTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusEmpty) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusEmpty#9d05049 as nil")
|
|
}
|
|
b.PutID(UserStatusEmptyTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusEmpty) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusEmpty#9d05049 as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusEmpty) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusEmpty#9d05049 to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusEmptyTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusEmpty#9d05049: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusEmpty) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusEmpty#9d05049 to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusEmpty) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusEmpty#9d05049 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusEmpty")
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusEmpty) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusEmpty#9d05049 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusEmpty"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusEmpty#9d05049: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// UserStatusOnline represents TL type `userStatusOnline#a4d64774`.
|
|
type UserStatusOnline struct {
|
|
// Point in time (Unix timestamp) when the user's online status will expire
|
|
Expires int32
|
|
}
|
|
|
|
// UserStatusOnlineTypeID is TL type id of UserStatusOnline.
|
|
const UserStatusOnlineTypeID = 0xa4d64774
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusOnline) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusOnline.
|
|
var (
|
|
_ bin.Encoder = &UserStatusOnline{}
|
|
_ bin.Decoder = &UserStatusOnline{}
|
|
_ bin.BareEncoder = &UserStatusOnline{}
|
|
_ bin.BareDecoder = &UserStatusOnline{}
|
|
|
|
_ UserStatusClass = &UserStatusOnline{}
|
|
)
|
|
|
|
func (u *UserStatusOnline) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
if !(u.Expires == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusOnline) String() string {
|
|
if u == nil {
|
|
return "UserStatusOnline(nil)"
|
|
}
|
|
type Alias UserStatusOnline
|
|
return fmt.Sprintf("UserStatusOnline%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusOnline) TypeID() uint32 {
|
|
return UserStatusOnlineTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusOnline) TypeName() string {
|
|
return "userStatusOnline"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusOnline) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusOnline",
|
|
ID: UserStatusOnlineTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Expires",
|
|
SchemaName: "expires",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusOnline) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOnline#a4d64774 as nil")
|
|
}
|
|
b.PutID(UserStatusOnlineTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusOnline) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOnline#a4d64774 as nil")
|
|
}
|
|
b.PutInt32(u.Expires)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusOnline) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOnline#a4d64774 to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusOnlineTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOnline#a4d64774: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusOnline) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOnline#a4d64774 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOnline#a4d64774: field expires: %w", err)
|
|
}
|
|
u.Expires = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusOnline) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOnline#a4d64774 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusOnline")
|
|
b.Comma()
|
|
b.FieldStart("expires")
|
|
b.PutInt32(u.Expires)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusOnline) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOnline#a4d64774 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusOnline"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOnline#a4d64774: %w", err)
|
|
}
|
|
case "expires":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOnline#a4d64774: field expires: %w", err)
|
|
}
|
|
u.Expires = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetExpires returns value of Expires field.
|
|
func (u *UserStatusOnline) GetExpires() (value int32) {
|
|
if u == nil {
|
|
return
|
|
}
|
|
return u.Expires
|
|
}
|
|
|
|
// UserStatusOffline represents TL type `userStatusOffline#d2b38d05`.
|
|
type UserStatusOffline struct {
|
|
// Point in time (Unix timestamp) when the user was last online
|
|
WasOnline int32
|
|
}
|
|
|
|
// UserStatusOfflineTypeID is TL type id of UserStatusOffline.
|
|
const UserStatusOfflineTypeID = 0xd2b38d05
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusOffline) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusOffline.
|
|
var (
|
|
_ bin.Encoder = &UserStatusOffline{}
|
|
_ bin.Decoder = &UserStatusOffline{}
|
|
_ bin.BareEncoder = &UserStatusOffline{}
|
|
_ bin.BareDecoder = &UserStatusOffline{}
|
|
|
|
_ UserStatusClass = &UserStatusOffline{}
|
|
)
|
|
|
|
func (u *UserStatusOffline) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
if !(u.WasOnline == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusOffline) String() string {
|
|
if u == nil {
|
|
return "UserStatusOffline(nil)"
|
|
}
|
|
type Alias UserStatusOffline
|
|
return fmt.Sprintf("UserStatusOffline%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusOffline) TypeID() uint32 {
|
|
return UserStatusOfflineTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusOffline) TypeName() string {
|
|
return "userStatusOffline"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusOffline) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusOffline",
|
|
ID: UserStatusOfflineTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "WasOnline",
|
|
SchemaName: "was_online",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusOffline) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOffline#d2b38d05 as nil")
|
|
}
|
|
b.PutID(UserStatusOfflineTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusOffline) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOffline#d2b38d05 as nil")
|
|
}
|
|
b.PutInt32(u.WasOnline)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusOffline) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOffline#d2b38d05 to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusOfflineTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOffline#d2b38d05: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusOffline) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOffline#d2b38d05 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOffline#d2b38d05: field was_online: %w", err)
|
|
}
|
|
u.WasOnline = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusOffline) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusOffline#d2b38d05 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusOffline")
|
|
b.Comma()
|
|
b.FieldStart("was_online")
|
|
b.PutInt32(u.WasOnline)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusOffline) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusOffline#d2b38d05 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusOffline"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOffline#d2b38d05: %w", err)
|
|
}
|
|
case "was_online":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusOffline#d2b38d05: field was_online: %w", err)
|
|
}
|
|
u.WasOnline = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetWasOnline returns value of WasOnline field.
|
|
func (u *UserStatusOffline) GetWasOnline() (value int32) {
|
|
if u == nil {
|
|
return
|
|
}
|
|
return u.WasOnline
|
|
}
|
|
|
|
// UserStatusRecently represents TL type `userStatusRecently#faa60b5`.
|
|
type UserStatusRecently struct {
|
|
// Exact user's status is hidden because the current user enabled
|
|
// userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium
|
|
ByMyPrivacySettings bool
|
|
}
|
|
|
|
// UserStatusRecentlyTypeID is TL type id of UserStatusRecently.
|
|
const UserStatusRecentlyTypeID = 0xfaa60b5
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusRecently) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusRecently.
|
|
var (
|
|
_ bin.Encoder = &UserStatusRecently{}
|
|
_ bin.Decoder = &UserStatusRecently{}
|
|
_ bin.BareEncoder = &UserStatusRecently{}
|
|
_ bin.BareDecoder = &UserStatusRecently{}
|
|
|
|
_ UserStatusClass = &UserStatusRecently{}
|
|
)
|
|
|
|
func (u *UserStatusRecently) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
if !(u.ByMyPrivacySettings == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusRecently) String() string {
|
|
if u == nil {
|
|
return "UserStatusRecently(nil)"
|
|
}
|
|
type Alias UserStatusRecently
|
|
return fmt.Sprintf("UserStatusRecently%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusRecently) TypeID() uint32 {
|
|
return UserStatusRecentlyTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusRecently) TypeName() string {
|
|
return "userStatusRecently"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusRecently) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusRecently",
|
|
ID: UserStatusRecentlyTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ByMyPrivacySettings",
|
|
SchemaName: "by_my_privacy_settings",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusRecently) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusRecently#faa60b5 as nil")
|
|
}
|
|
b.PutID(UserStatusRecentlyTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusRecently) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusRecently#faa60b5 as nil")
|
|
}
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusRecently) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusRecently#faa60b5 to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusRecentlyTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusRecently#faa60b5: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusRecently) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusRecently#faa60b5 to nil")
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusRecently#faa60b5: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusRecently) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusRecently#faa60b5 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusRecently")
|
|
b.Comma()
|
|
b.FieldStart("by_my_privacy_settings")
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusRecently) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusRecently#faa60b5 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusRecently"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusRecently#faa60b5: %w", err)
|
|
}
|
|
case "by_my_privacy_settings":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusRecently#faa60b5: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetByMyPrivacySettings returns value of ByMyPrivacySettings field.
|
|
func (u *UserStatusRecently) GetByMyPrivacySettings() (value bool) {
|
|
if u == nil {
|
|
return
|
|
}
|
|
return u.ByMyPrivacySettings
|
|
}
|
|
|
|
// UserStatusLastWeek represents TL type `userStatusLastWeek#12801b57`.
|
|
type UserStatusLastWeek struct {
|
|
// Exact user's status is hidden because the current user enabled
|
|
// userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium
|
|
ByMyPrivacySettings bool
|
|
}
|
|
|
|
// UserStatusLastWeekTypeID is TL type id of UserStatusLastWeek.
|
|
const UserStatusLastWeekTypeID = 0x12801b57
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusLastWeek) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusLastWeek.
|
|
var (
|
|
_ bin.Encoder = &UserStatusLastWeek{}
|
|
_ bin.Decoder = &UserStatusLastWeek{}
|
|
_ bin.BareEncoder = &UserStatusLastWeek{}
|
|
_ bin.BareDecoder = &UserStatusLastWeek{}
|
|
|
|
_ UserStatusClass = &UserStatusLastWeek{}
|
|
)
|
|
|
|
func (u *UserStatusLastWeek) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
if !(u.ByMyPrivacySettings == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusLastWeek) String() string {
|
|
if u == nil {
|
|
return "UserStatusLastWeek(nil)"
|
|
}
|
|
type Alias UserStatusLastWeek
|
|
return fmt.Sprintf("UserStatusLastWeek%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusLastWeek) TypeID() uint32 {
|
|
return UserStatusLastWeekTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusLastWeek) TypeName() string {
|
|
return "userStatusLastWeek"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusLastWeek) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusLastWeek",
|
|
ID: UserStatusLastWeekTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ByMyPrivacySettings",
|
|
SchemaName: "by_my_privacy_settings",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusLastWeek) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastWeek#12801b57 as nil")
|
|
}
|
|
b.PutID(UserStatusLastWeekTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusLastWeek) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastWeek#12801b57 as nil")
|
|
}
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusLastWeek) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastWeek#12801b57 to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusLastWeekTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastWeek#12801b57: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusLastWeek) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastWeek#12801b57 to nil")
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastWeek#12801b57: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusLastWeek) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastWeek#12801b57 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusLastWeek")
|
|
b.Comma()
|
|
b.FieldStart("by_my_privacy_settings")
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusLastWeek) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastWeek#12801b57 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusLastWeek"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastWeek#12801b57: %w", err)
|
|
}
|
|
case "by_my_privacy_settings":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastWeek#12801b57: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetByMyPrivacySettings returns value of ByMyPrivacySettings field.
|
|
func (u *UserStatusLastWeek) GetByMyPrivacySettings() (value bool) {
|
|
if u == nil {
|
|
return
|
|
}
|
|
return u.ByMyPrivacySettings
|
|
}
|
|
|
|
// UserStatusLastMonth represents TL type `userStatusLastMonth#b8cb29fc`.
|
|
type UserStatusLastMonth struct {
|
|
// Exact user's status is hidden because the current user enabled
|
|
// userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium
|
|
ByMyPrivacySettings bool
|
|
}
|
|
|
|
// UserStatusLastMonthTypeID is TL type id of UserStatusLastMonth.
|
|
const UserStatusLastMonthTypeID = 0xb8cb29fc
|
|
|
|
// construct implements constructor of UserStatusClass.
|
|
func (u UserStatusLastMonth) construct() UserStatusClass { return &u }
|
|
|
|
// Ensuring interfaces in compile-time for UserStatusLastMonth.
|
|
var (
|
|
_ bin.Encoder = &UserStatusLastMonth{}
|
|
_ bin.Decoder = &UserStatusLastMonth{}
|
|
_ bin.BareEncoder = &UserStatusLastMonth{}
|
|
_ bin.BareDecoder = &UserStatusLastMonth{}
|
|
|
|
_ UserStatusClass = &UserStatusLastMonth{}
|
|
)
|
|
|
|
func (u *UserStatusLastMonth) Zero() bool {
|
|
if u == nil {
|
|
return true
|
|
}
|
|
if !(u.ByMyPrivacySettings == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (u *UserStatusLastMonth) String() string {
|
|
if u == nil {
|
|
return "UserStatusLastMonth(nil)"
|
|
}
|
|
type Alias UserStatusLastMonth
|
|
return fmt.Sprintf("UserStatusLastMonth%+v", Alias(*u))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*UserStatusLastMonth) TypeID() uint32 {
|
|
return UserStatusLastMonthTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*UserStatusLastMonth) TypeName() string {
|
|
return "userStatusLastMonth"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (u *UserStatusLastMonth) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "userStatusLastMonth",
|
|
ID: UserStatusLastMonthTypeID,
|
|
}
|
|
if u == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ByMyPrivacySettings",
|
|
SchemaName: "by_my_privacy_settings",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (u *UserStatusLastMonth) Encode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastMonth#b8cb29fc as nil")
|
|
}
|
|
b.PutID(UserStatusLastMonthTypeID)
|
|
return u.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (u *UserStatusLastMonth) EncodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastMonth#b8cb29fc as nil")
|
|
}
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (u *UserStatusLastMonth) Decode(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastMonth#b8cb29fc to nil")
|
|
}
|
|
if err := b.ConsumeID(UserStatusLastMonthTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastMonth#b8cb29fc: %w", err)
|
|
}
|
|
return u.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (u *UserStatusLastMonth) DecodeBare(b *bin.Buffer) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastMonth#b8cb29fc to nil")
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastMonth#b8cb29fc: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (u *UserStatusLastMonth) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't encode userStatusLastMonth#b8cb29fc as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("userStatusLastMonth")
|
|
b.Comma()
|
|
b.FieldStart("by_my_privacy_settings")
|
|
b.PutBool(u.ByMyPrivacySettings)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (u *UserStatusLastMonth) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if u == nil {
|
|
return fmt.Errorf("can't decode userStatusLastMonth#b8cb29fc to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("userStatusLastMonth"); err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastMonth#b8cb29fc: %w", err)
|
|
}
|
|
case "by_my_privacy_settings":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode userStatusLastMonth#b8cb29fc: field by_my_privacy_settings: %w", err)
|
|
}
|
|
u.ByMyPrivacySettings = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetByMyPrivacySettings returns value of ByMyPrivacySettings field.
|
|
func (u *UserStatusLastMonth) GetByMyPrivacySettings() (value bool) {
|
|
if u == nil {
|
|
return
|
|
}
|
|
return u.ByMyPrivacySettings
|
|
}
|
|
|
|
// UserStatusClassName is schema name of UserStatusClass.
|
|
const UserStatusClassName = "UserStatus"
|
|
|
|
// UserStatusClass represents UserStatus generic type.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tdapi.DecodeUserStatus(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tdapi.UserStatusEmpty: // userStatusEmpty#9d05049
|
|
// case *tdapi.UserStatusOnline: // userStatusOnline#a4d64774
|
|
// case *tdapi.UserStatusOffline: // userStatusOffline#d2b38d05
|
|
// case *tdapi.UserStatusRecently: // userStatusRecently#faa60b5
|
|
// case *tdapi.UserStatusLastWeek: // userStatusLastWeek#12801b57
|
|
// case *tdapi.UserStatusLastMonth: // userStatusLastMonth#b8cb29fc
|
|
// default: panic(v)
|
|
// }
|
|
type UserStatusClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() UserStatusClass
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
TypeID() uint32
|
|
// TypeName returns name of type in TL schema.
|
|
TypeName() string
|
|
// String implements fmt.Stringer.
|
|
String() string
|
|
// Zero returns true if current object has a zero value.
|
|
Zero() bool
|
|
|
|
EncodeTDLibJSON(b tdjson.Encoder) error
|
|
DecodeTDLibJSON(b tdjson.Decoder) error
|
|
}
|
|
|
|
// DecodeUserStatus implements binary de-serialization for UserStatusClass.
|
|
func DecodeUserStatus(buf *bin.Buffer) (UserStatusClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case UserStatusEmptyTypeID:
|
|
// Decoding userStatusEmpty#9d05049.
|
|
v := UserStatusEmpty{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case UserStatusOnlineTypeID:
|
|
// Decoding userStatusOnline#a4d64774.
|
|
v := UserStatusOnline{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case UserStatusOfflineTypeID:
|
|
// Decoding userStatusOffline#d2b38d05.
|
|
v := UserStatusOffline{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case UserStatusRecentlyTypeID:
|
|
// Decoding userStatusRecently#faa60b5.
|
|
v := UserStatusRecently{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case UserStatusLastWeekTypeID:
|
|
// Decoding userStatusLastWeek#12801b57.
|
|
v := UserStatusLastWeek{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case UserStatusLastMonthTypeID:
|
|
// Decoding userStatusLastMonth#b8cb29fc.
|
|
v := UserStatusLastMonth{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// DecodeTDLibJSONUserStatus implements binary de-serialization for UserStatusClass.
|
|
func DecodeTDLibJSONUserStatus(buf tdjson.Decoder) (UserStatusClass, error) {
|
|
id, err := buf.FindTypeID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case "userStatusEmpty":
|
|
// Decoding userStatusEmpty#9d05049.
|
|
v := UserStatusEmpty{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "userStatusOnline":
|
|
// Decoding userStatusOnline#a4d64774.
|
|
v := UserStatusOnline{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "userStatusOffline":
|
|
// Decoding userStatusOffline#d2b38d05.
|
|
v := UserStatusOffline{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "userStatusRecently":
|
|
// Decoding userStatusRecently#faa60b5.
|
|
v := UserStatusRecently{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "userStatusLastWeek":
|
|
// Decoding userStatusLastWeek#12801b57.
|
|
v := UserStatusLastWeek{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "userStatusLastMonth":
|
|
// Decoding userStatusLastMonth#b8cb29fc.
|
|
v := UserStatusLastMonth{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode UserStatusClass: %w", tdjson.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// UserStatus boxes the UserStatusClass providing a helper.
|
|
type UserStatusBox struct {
|
|
UserStatus UserStatusClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for UserStatusBox.
|
|
func (b *UserStatusBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode UserStatusBox to nil")
|
|
}
|
|
v, err := DecodeUserStatus(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.UserStatus = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for UserStatusBox.
|
|
func (b *UserStatusBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.UserStatus == nil {
|
|
return fmt.Errorf("unable to encode UserStatusClass as nil")
|
|
}
|
|
return b.UserStatus.Encode(buf)
|
|
}
|
|
|
|
// DecodeTDLibJSON implements bin.Decoder for UserStatusBox.
|
|
func (b *UserStatusBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode UserStatusBox to nil")
|
|
}
|
|
v, err := DecodeTDLibJSONUserStatus(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.UserStatus = v
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements bin.Encode for UserStatusBox.
|
|
func (b *UserStatusBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
|
|
if b == nil || b.UserStatus == nil {
|
|
return fmt.Errorf("unable to encode UserStatusClass as nil")
|
|
}
|
|
return b.UserStatus.EncodeTDLibJSON(buf)
|
|
}
|