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 MessagesChatInviteJoinResultOk struct {
Updates UpdatesClass
}
const MessagesChatInviteJoinResultOkTypeID = 0x445663a7
func (c MessagesChatInviteJoinResultOk ) construct () MessagesChatInviteJoinResultClass { return &c }
var (
_ bin .Encoder = &MessagesChatInviteJoinResultOk {}
_ bin .Decoder = &MessagesChatInviteJoinResultOk {}
_ bin .BareEncoder = &MessagesChatInviteJoinResultOk {}
_ bin .BareDecoder = &MessagesChatInviteJoinResultOk {}
_ MessagesChatInviteJoinResultClass = &MessagesChatInviteJoinResultOk {}
)
func (c *MessagesChatInviteJoinResultOk ) Zero () bool {
if c == nil {
return true
}
if !(c .Updates == nil ) {
return false
}
return true
}
func (c *MessagesChatInviteJoinResultOk ) String () string {
if c == nil {
return "MessagesChatInviteJoinResultOk(nil)"
}
type Alias MessagesChatInviteJoinResultOk
return fmt .Sprintf ("MessagesChatInviteJoinResultOk%+v" , Alias (*c ))
}
func (c *MessagesChatInviteJoinResultOk ) FillFrom (from interface {
GetUpdates () (value UpdatesClass )
}) {
c .Updates = from .GetUpdates ()
}
func (*MessagesChatInviteJoinResultOk ) TypeID () uint32 {
return MessagesChatInviteJoinResultOkTypeID
}
func (*MessagesChatInviteJoinResultOk ) TypeName () string {
return "messages.chatInviteJoinResultOk"
}
func (c *MessagesChatInviteJoinResultOk ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.chatInviteJoinResultOk" ,
ID : MessagesChatInviteJoinResultOkTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Updates" ,
SchemaName : "updates" ,
},
}
return typ
}
func (c *MessagesChatInviteJoinResultOk ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatInviteJoinResultOk#445663a7 as nil" )
}
b .PutID (MessagesChatInviteJoinResultOkTypeID )
return c .EncodeBare (b )
}
func (c *MessagesChatInviteJoinResultOk ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatInviteJoinResultOk#445663a7 as nil" )
}
if c .Updates == nil {
return fmt .Errorf ("unable to encode messages.chatInviteJoinResultOk#445663a7: field updates is nil" )
}
if err := c .Updates .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.chatInviteJoinResultOk#445663a7: field updates: %w" , err )
}
return nil
}
func (c *MessagesChatInviteJoinResultOk ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatInviteJoinResultOk#445663a7 to nil" )
}
if err := b .ConsumeID (MessagesChatInviteJoinResultOkTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultOk#445663a7: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesChatInviteJoinResultOk ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatInviteJoinResultOk#445663a7 to nil" )
}
{
value , err := DecodeUpdates (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultOk#445663a7: field updates: %w" , err )
}
c .Updates = value
}
return nil
}
func (c *MessagesChatInviteJoinResultOk ) GetUpdates () (value UpdatesClass ) {
if c == nil {
return
}
return c .Updates
}
type MessagesChatInviteJoinResultWebView struct {
BotID int64
Webview WebViewResultURL
Users []UserClass
}
const MessagesChatInviteJoinResultWebViewTypeID = 0x2f51c337
func (c MessagesChatInviteJoinResultWebView ) construct () MessagesChatInviteJoinResultClass { return &c }
var (
_ bin .Encoder = &MessagesChatInviteJoinResultWebView {}
_ bin .Decoder = &MessagesChatInviteJoinResultWebView {}
_ bin .BareEncoder = &MessagesChatInviteJoinResultWebView {}
_ bin .BareDecoder = &MessagesChatInviteJoinResultWebView {}
_ MessagesChatInviteJoinResultClass = &MessagesChatInviteJoinResultWebView {}
)
func (c *MessagesChatInviteJoinResultWebView ) Zero () bool {
if c == nil {
return true
}
if !(c .BotID == 0 ) {
return false
}
if !(c .Webview .Zero ()) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *MessagesChatInviteJoinResultWebView ) String () string {
if c == nil {
return "MessagesChatInviteJoinResultWebView(nil)"
}
type Alias MessagesChatInviteJoinResultWebView
return fmt .Sprintf ("MessagesChatInviteJoinResultWebView%+v" , Alias (*c ))
}
func (c *MessagesChatInviteJoinResultWebView ) FillFrom (from interface {
GetBotID () (value int64 )
GetWebview () (value WebViewResultURL )
GetUsers () (value []UserClass )
}) {
c .BotID = from .GetBotID ()
c .Webview = from .GetWebview ()
c .Users = from .GetUsers ()
}
func (*MessagesChatInviteJoinResultWebView ) TypeID () uint32 {
return MessagesChatInviteJoinResultWebViewTypeID
}
func (*MessagesChatInviteJoinResultWebView ) TypeName () string {
return "messages.chatInviteJoinResultWebView"
}
func (c *MessagesChatInviteJoinResultWebView ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.chatInviteJoinResultWebView" ,
ID : MessagesChatInviteJoinResultWebViewTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "Webview" ,
SchemaName : "webview" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *MessagesChatInviteJoinResultWebView ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatInviteJoinResultWebView#2f51c337 as nil" )
}
b .PutID (MessagesChatInviteJoinResultWebViewTypeID )
return c .EncodeBare (b )
}
func (c *MessagesChatInviteJoinResultWebView ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.chatInviteJoinResultWebView#2f51c337 as nil" )
}
b .PutLong (c .BotID )
if err := c .Webview .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.chatInviteJoinResultWebView#2f51c337: field webview: %w" , err )
}
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.chatInviteJoinResultWebView#2f51c337: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.chatInviteJoinResultWebView#2f51c337: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *MessagesChatInviteJoinResultWebView ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatInviteJoinResultWebView#2f51c337 to nil" )
}
if err := b .ConsumeID (MessagesChatInviteJoinResultWebViewTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultWebView#2f51c337: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesChatInviteJoinResultWebView ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.chatInviteJoinResultWebView#2f51c337 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultWebView#2f51c337: field bot_id: %w" , err )
}
c .BotID = value
}
{
if err := c .Webview .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultWebView#2f51c337: field webview: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultWebView#2f51c337: field users: %w" , err )
}
if headerLen > 0 {
c .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.chatInviteJoinResultWebView#2f51c337: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *MessagesChatInviteJoinResultWebView ) GetBotID () (value int64 ) {
if c == nil {
return
}
return c .BotID
}
func (c *MessagesChatInviteJoinResultWebView ) GetWebview () (value WebViewResultURL ) {
if c == nil {
return
}
return c .Webview
}
func (c *MessagesChatInviteJoinResultWebView ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *MessagesChatInviteJoinResultWebView ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
const MessagesChatInviteJoinResultClassName = "messages.ChatInviteJoinResult"
type MessagesChatInviteJoinResultClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesChatInviteJoinResultClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeMessagesChatInviteJoinResult (buf *bin .Buffer ) (MessagesChatInviteJoinResultClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesChatInviteJoinResultOkTypeID :
v := MessagesChatInviteJoinResultOk {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesChatInviteJoinResultClass: %w" , err )
}
return &v , nil
case MessagesChatInviteJoinResultWebViewTypeID :
v := MessagesChatInviteJoinResultWebView {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesChatInviteJoinResultClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesChatInviteJoinResultClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesChatInviteJoinResultBox struct {
ChatInviteJoinResult MessagesChatInviteJoinResultClass
}
func (b *MessagesChatInviteJoinResultBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesChatInviteJoinResultBox to nil" )
}
v , err := DecodeMessagesChatInviteJoinResult (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatInviteJoinResult = v
return nil
}
func (b *MessagesChatInviteJoinResultBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatInviteJoinResult == nil {
return fmt .Errorf ("unable to encode MessagesChatInviteJoinResultClass as nil" )
}
return b .ChatInviteJoinResult .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .