package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type UserStatusEmpty struct {
}
const UserStatusEmptyTypeID = 0x9d05049
func (u UserStatusEmpty ) construct () UserStatusClass { return &u }
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
}
func (u *UserStatusEmpty ) String () string {
if u == nil {
return "UserStatusEmpty(nil)"
}
type Alias UserStatusEmpty
return fmt .Sprintf ("UserStatusEmpty%+v" , Alias (*u ))
}
func (*UserStatusEmpty ) TypeID () uint32 {
return UserStatusEmptyTypeID
}
func (*UserStatusEmpty ) TypeName () string {
return "userStatusEmpty"
}
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
}
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 )
}
func (u *UserStatusEmpty ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusEmpty#9d05049 as nil" )
}
return nil
}
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 )
}
func (u *UserStatusEmpty ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusEmpty#9d05049 to nil" )
}
return nil
}
type UserStatusOnline struct {
Expires int
}
const UserStatusOnlineTypeID = 0xedb93949
func (u UserStatusOnline ) construct () UserStatusClass { return &u }
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
}
func (u *UserStatusOnline ) String () string {
if u == nil {
return "UserStatusOnline(nil)"
}
type Alias UserStatusOnline
return fmt .Sprintf ("UserStatusOnline%+v" , Alias (*u ))
}
func (u *UserStatusOnline ) FillFrom (from interface {
GetExpires () (value int )
}) {
u .Expires = from .GetExpires ()
}
func (*UserStatusOnline ) TypeID () uint32 {
return UserStatusOnlineTypeID
}
func (*UserStatusOnline ) TypeName () string {
return "userStatusOnline"
}
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
}
func (u *UserStatusOnline ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusOnline#edb93949 as nil" )
}
b .PutID (UserStatusOnlineTypeID )
return u .EncodeBare (b )
}
func (u *UserStatusOnline ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusOnline#edb93949 as nil" )
}
b .PutInt (u .Expires )
return nil
}
func (u *UserStatusOnline ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusOnline#edb93949 to nil" )
}
if err := b .ConsumeID (UserStatusOnlineTypeID ); err != nil {
return fmt .Errorf ("unable to decode userStatusOnline#edb93949: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserStatusOnline ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusOnline#edb93949 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode userStatusOnline#edb93949: field expires: %w" , err )
}
u .Expires = value
}
return nil
}
func (u *UserStatusOnline ) GetExpires () (value int ) {
if u == nil {
return
}
return u .Expires
}
type UserStatusOffline struct {
WasOnline int
}
const UserStatusOfflineTypeID = 0x8c703f
func (u UserStatusOffline ) construct () UserStatusClass { return &u }
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
}
func (u *UserStatusOffline ) String () string {
if u == nil {
return "UserStatusOffline(nil)"
}
type Alias UserStatusOffline
return fmt .Sprintf ("UserStatusOffline%+v" , Alias (*u ))
}
func (u *UserStatusOffline ) FillFrom (from interface {
GetWasOnline () (value int )
}) {
u .WasOnline = from .GetWasOnline ()
}
func (*UserStatusOffline ) TypeID () uint32 {
return UserStatusOfflineTypeID
}
func (*UserStatusOffline ) TypeName () string {
return "userStatusOffline"
}
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
}
func (u *UserStatusOffline ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusOffline#8c703f as nil" )
}
b .PutID (UserStatusOfflineTypeID )
return u .EncodeBare (b )
}
func (u *UserStatusOffline ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusOffline#8c703f as nil" )
}
b .PutInt (u .WasOnline )
return nil
}
func (u *UserStatusOffline ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusOffline#8c703f to nil" )
}
if err := b .ConsumeID (UserStatusOfflineTypeID ); err != nil {
return fmt .Errorf ("unable to decode userStatusOffline#8c703f: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserStatusOffline ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusOffline#8c703f to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode userStatusOffline#8c703f: field was_online: %w" , err )
}
u .WasOnline = value
}
return nil
}
func (u *UserStatusOffline ) GetWasOnline () (value int ) {
if u == nil {
return
}
return u .WasOnline
}
type UserStatusRecently struct {
}
const UserStatusRecentlyTypeID = 0xe26f42f1
func (u UserStatusRecently ) construct () UserStatusClass { return &u }
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
}
return true
}
func (u *UserStatusRecently ) String () string {
if u == nil {
return "UserStatusRecently(nil)"
}
type Alias UserStatusRecently
return fmt .Sprintf ("UserStatusRecently%+v" , Alias (*u ))
}
func (*UserStatusRecently ) TypeID () uint32 {
return UserStatusRecentlyTypeID
}
func (*UserStatusRecently ) TypeName () string {
return "userStatusRecently"
}
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 {}
return typ
}
func (u *UserStatusRecently ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusRecently#e26f42f1 as nil" )
}
b .PutID (UserStatusRecentlyTypeID )
return u .EncodeBare (b )
}
func (u *UserStatusRecently ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusRecently#e26f42f1 as nil" )
}
return nil
}
func (u *UserStatusRecently ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusRecently#e26f42f1 to nil" )
}
if err := b .ConsumeID (UserStatusRecentlyTypeID ); err != nil {
return fmt .Errorf ("unable to decode userStatusRecently#e26f42f1: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserStatusRecently ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusRecently#e26f42f1 to nil" )
}
return nil
}
type UserStatusLastWeek struct {
}
const UserStatusLastWeekTypeID = 0x7bf09fc
func (u UserStatusLastWeek ) construct () UserStatusClass { return &u }
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
}
return true
}
func (u *UserStatusLastWeek ) String () string {
if u == nil {
return "UserStatusLastWeek(nil)"
}
type Alias UserStatusLastWeek
return fmt .Sprintf ("UserStatusLastWeek%+v" , Alias (*u ))
}
func (*UserStatusLastWeek ) TypeID () uint32 {
return UserStatusLastWeekTypeID
}
func (*UserStatusLastWeek ) TypeName () string {
return "userStatusLastWeek"
}
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 {}
return typ
}
func (u *UserStatusLastWeek ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusLastWeek#7bf09fc as nil" )
}
b .PutID (UserStatusLastWeekTypeID )
return u .EncodeBare (b )
}
func (u *UserStatusLastWeek ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusLastWeek#7bf09fc as nil" )
}
return nil
}
func (u *UserStatusLastWeek ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusLastWeek#7bf09fc to nil" )
}
if err := b .ConsumeID (UserStatusLastWeekTypeID ); err != nil {
return fmt .Errorf ("unable to decode userStatusLastWeek#7bf09fc: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserStatusLastWeek ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusLastWeek#7bf09fc to nil" )
}
return nil
}
type UserStatusLastMonth struct {
}
const UserStatusLastMonthTypeID = 0x77ebc742
func (u UserStatusLastMonth ) construct () UserStatusClass { return &u }
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
}
return true
}
func (u *UserStatusLastMonth ) String () string {
if u == nil {
return "UserStatusLastMonth(nil)"
}
type Alias UserStatusLastMonth
return fmt .Sprintf ("UserStatusLastMonth%+v" , Alias (*u ))
}
func (*UserStatusLastMonth ) TypeID () uint32 {
return UserStatusLastMonthTypeID
}
func (*UserStatusLastMonth ) TypeName () string {
return "userStatusLastMonth"
}
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 {}
return typ
}
func (u *UserStatusLastMonth ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusLastMonth#77ebc742 as nil" )
}
b .PutID (UserStatusLastMonthTypeID )
return u .EncodeBare (b )
}
func (u *UserStatusLastMonth ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userStatusLastMonth#77ebc742 as nil" )
}
return nil
}
func (u *UserStatusLastMonth ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusLastMonth#77ebc742 to nil" )
}
if err := b .ConsumeID (UserStatusLastMonthTypeID ); err != nil {
return fmt .Errorf ("unable to decode userStatusLastMonth#77ebc742: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserStatusLastMonth ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userStatusLastMonth#77ebc742 to nil" )
}
return nil
}
const UserStatusClassName = "UserStatus"
type UserStatusClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UserStatusClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeUserStatus (buf *bin .Buffer ) (UserStatusClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UserStatusEmptyTypeID :
v := UserStatusEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserStatusClass: %w" , err )
}
return &v , nil
case UserStatusOnlineTypeID :
v := UserStatusOnline {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserStatusClass: %w" , err )
}
return &v , nil
case UserStatusOfflineTypeID :
v := UserStatusOffline {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserStatusClass: %w" , err )
}
return &v , nil
case UserStatusRecentlyTypeID :
v := UserStatusRecently {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserStatusClass: %w" , err )
}
return &v , nil
case UserStatusLastWeekTypeID :
v := UserStatusLastWeek {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserStatusClass: %w" , err )
}
return &v , nil
case UserStatusLastMonthTypeID :
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 ))
}
}
type UserStatusBox struct {
UserStatus UserStatusClass
}
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
}
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 )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .