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 ChatParticipant struct {
UserID int64
InviterID int64
Date int
}
const ChatParticipantTypeID = 0xc02d4007
func (c ChatParticipant ) construct () ChatParticipantClass { return &c }
var (
_ bin .Encoder = &ChatParticipant {}
_ bin .Decoder = &ChatParticipant {}
_ bin .BareEncoder = &ChatParticipant {}
_ bin .BareDecoder = &ChatParticipant {}
_ ChatParticipantClass = &ChatParticipant {}
)
func (c *ChatParticipant ) Zero () bool {
if c == nil {
return true
}
if !(c .UserID == 0 ) {
return false
}
if !(c .InviterID == 0 ) {
return false
}
if !(c .Date == 0 ) {
return false
}
return true
}
func (c *ChatParticipant ) String () string {
if c == nil {
return "ChatParticipant(nil)"
}
type Alias ChatParticipant
return fmt .Sprintf ("ChatParticipant%+v" , Alias (*c ))
}
func (c *ChatParticipant ) FillFrom (from interface {
GetUserID () (value int64 )
GetInviterID () (value int64 )
GetDate () (value int )
}) {
c .UserID = from .GetUserID ()
c .InviterID = from .GetInviterID ()
c .Date = from .GetDate ()
}
func (*ChatParticipant ) TypeID () uint32 {
return ChatParticipantTypeID
}
func (*ChatParticipant ) TypeName () string {
return "chatParticipant"
}
func (c *ChatParticipant ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatParticipant" ,
ID : ChatParticipantTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "InviterID" ,
SchemaName : "inviter_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (c *ChatParticipant ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipant#c02d4007 as nil" )
}
b .PutID (ChatParticipantTypeID )
return c .EncodeBare (b )
}
func (c *ChatParticipant ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipant#c02d4007 as nil" )
}
b .PutLong (c .UserID )
b .PutLong (c .InviterID )
b .PutInt (c .Date )
return nil
}
func (c *ChatParticipant ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipant#c02d4007 to nil" )
}
if err := b .ConsumeID (ChatParticipantTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatParticipant#c02d4007: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatParticipant ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipant#c02d4007 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipant#c02d4007: field user_id: %w" , err )
}
c .UserID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipant#c02d4007: field inviter_id: %w" , err )
}
c .InviterID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipant#c02d4007: field date: %w" , err )
}
c .Date = value
}
return nil
}
func (c *ChatParticipant ) GetUserID () (value int64 ) {
if c == nil {
return
}
return c .UserID
}
func (c *ChatParticipant ) GetInviterID () (value int64 ) {
if c == nil {
return
}
return c .InviterID
}
func (c *ChatParticipant ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
type ChatParticipantCreator struct {
UserID int64
}
const ChatParticipantCreatorTypeID = 0xe46bcee4
func (c ChatParticipantCreator ) construct () ChatParticipantClass { return &c }
var (
_ bin .Encoder = &ChatParticipantCreator {}
_ bin .Decoder = &ChatParticipantCreator {}
_ bin .BareEncoder = &ChatParticipantCreator {}
_ bin .BareDecoder = &ChatParticipantCreator {}
_ ChatParticipantClass = &ChatParticipantCreator {}
)
func (c *ChatParticipantCreator ) Zero () bool {
if c == nil {
return true
}
if !(c .UserID == 0 ) {
return false
}
return true
}
func (c *ChatParticipantCreator ) String () string {
if c == nil {
return "ChatParticipantCreator(nil)"
}
type Alias ChatParticipantCreator
return fmt .Sprintf ("ChatParticipantCreator%+v" , Alias (*c ))
}
func (c *ChatParticipantCreator ) FillFrom (from interface {
GetUserID () (value int64 )
}) {
c .UserID = from .GetUserID ()
}
func (*ChatParticipantCreator ) TypeID () uint32 {
return ChatParticipantCreatorTypeID
}
func (*ChatParticipantCreator ) TypeName () string {
return "chatParticipantCreator"
}
func (c *ChatParticipantCreator ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatParticipantCreator" ,
ID : ChatParticipantCreatorTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
}
return typ
}
func (c *ChatParticipantCreator ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantCreator#e46bcee4 as nil" )
}
b .PutID (ChatParticipantCreatorTypeID )
return c .EncodeBare (b )
}
func (c *ChatParticipantCreator ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantCreator#e46bcee4 as nil" )
}
b .PutLong (c .UserID )
return nil
}
func (c *ChatParticipantCreator ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantCreator#e46bcee4 to nil" )
}
if err := b .ConsumeID (ChatParticipantCreatorTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatParticipantCreator#e46bcee4: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatParticipantCreator ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantCreator#e46bcee4 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantCreator#e46bcee4: field user_id: %w" , err )
}
c .UserID = value
}
return nil
}
func (c *ChatParticipantCreator ) GetUserID () (value int64 ) {
if c == nil {
return
}
return c .UserID
}
type ChatParticipantAdmin struct {
UserID int64
InviterID int64
Date int
}
const ChatParticipantAdminTypeID = 0xa0933f5b
func (c ChatParticipantAdmin ) construct () ChatParticipantClass { return &c }
var (
_ bin .Encoder = &ChatParticipantAdmin {}
_ bin .Decoder = &ChatParticipantAdmin {}
_ bin .BareEncoder = &ChatParticipantAdmin {}
_ bin .BareDecoder = &ChatParticipantAdmin {}
_ ChatParticipantClass = &ChatParticipantAdmin {}
)
func (c *ChatParticipantAdmin ) Zero () bool {
if c == nil {
return true
}
if !(c .UserID == 0 ) {
return false
}
if !(c .InviterID == 0 ) {
return false
}
if !(c .Date == 0 ) {
return false
}
return true
}
func (c *ChatParticipantAdmin ) String () string {
if c == nil {
return "ChatParticipantAdmin(nil)"
}
type Alias ChatParticipantAdmin
return fmt .Sprintf ("ChatParticipantAdmin%+v" , Alias (*c ))
}
func (c *ChatParticipantAdmin ) FillFrom (from interface {
GetUserID () (value int64 )
GetInviterID () (value int64 )
GetDate () (value int )
}) {
c .UserID = from .GetUserID ()
c .InviterID = from .GetInviterID ()
c .Date = from .GetDate ()
}
func (*ChatParticipantAdmin ) TypeID () uint32 {
return ChatParticipantAdminTypeID
}
func (*ChatParticipantAdmin ) TypeName () string {
return "chatParticipantAdmin"
}
func (c *ChatParticipantAdmin ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatParticipantAdmin" ,
ID : ChatParticipantAdminTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "InviterID" ,
SchemaName : "inviter_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (c *ChatParticipantAdmin ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantAdmin#a0933f5b as nil" )
}
b .PutID (ChatParticipantAdminTypeID )
return c .EncodeBare (b )
}
func (c *ChatParticipantAdmin ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantAdmin#a0933f5b as nil" )
}
b .PutLong (c .UserID )
b .PutLong (c .InviterID )
b .PutInt (c .Date )
return nil
}
func (c *ChatParticipantAdmin ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantAdmin#a0933f5b to nil" )
}
if err := b .ConsumeID (ChatParticipantAdminTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatParticipantAdmin#a0933f5b: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatParticipantAdmin ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantAdmin#a0933f5b to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantAdmin#a0933f5b: field user_id: %w" , err )
}
c .UserID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantAdmin#a0933f5b: field inviter_id: %w" , err )
}
c .InviterID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantAdmin#a0933f5b: field date: %w" , err )
}
c .Date = value
}
return nil
}
func (c *ChatParticipantAdmin ) GetUserID () (value int64 ) {
if c == nil {
return
}
return c .UserID
}
func (c *ChatParticipantAdmin ) GetInviterID () (value int64 ) {
if c == nil {
return
}
return c .InviterID
}
func (c *ChatParticipantAdmin ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
const ChatParticipantClassName = "ChatParticipant"
type ChatParticipantClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatParticipantClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetUserID () (value int64 )
}
func DecodeChatParticipant (buf *bin .Buffer ) (ChatParticipantClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatParticipantTypeID :
v := ChatParticipant {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatParticipantClass: %w" , err )
}
return &v , nil
case ChatParticipantCreatorTypeID :
v := ChatParticipantCreator {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatParticipantClass: %w" , err )
}
return &v , nil
case ChatParticipantAdminTypeID :
v := ChatParticipantAdmin {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatParticipantClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatParticipantClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatParticipantBox struct {
ChatParticipant ChatParticipantClass
}
func (b *ChatParticipantBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatParticipantBox to nil" )
}
v , err := DecodeChatParticipant (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatParticipant = v
return nil
}
func (b *ChatParticipantBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatParticipant == nil {
return fmt .Errorf ("unable to encode ChatParticipantClass as nil" )
}
return b .ChatParticipant .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 .