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 ChatInviteImporter struct {
Flags bin .Fields
Requested bool
ViaChatlist bool
UserID int64
Date int
About string
ApprovedBy int64
}
const ChatInviteImporterTypeID = 0x8c5adfd9
var (
_ bin .Encoder = &ChatInviteImporter {}
_ bin .Decoder = &ChatInviteImporter {}
_ bin .BareEncoder = &ChatInviteImporter {}
_ bin .BareDecoder = &ChatInviteImporter {}
)
func (c *ChatInviteImporter ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Requested == false ) {
return false
}
if !(c .ViaChatlist == false ) {
return false
}
if !(c .UserID == 0 ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .About == "" ) {
return false
}
if !(c .ApprovedBy == 0 ) {
return false
}
return true
}
func (c *ChatInviteImporter ) String () string {
if c == nil {
return "ChatInviteImporter(nil)"
}
type Alias ChatInviteImporter
return fmt .Sprintf ("ChatInviteImporter%+v" , Alias (*c ))
}
func (c *ChatInviteImporter ) FillFrom (from interface {
GetRequested () (value bool )
GetViaChatlist () (value bool )
GetUserID () (value int64 )
GetDate () (value int )
GetAbout () (value string , ok bool )
GetApprovedBy () (value int64 , ok bool )
}) {
c .Requested = from .GetRequested ()
c .ViaChatlist = from .GetViaChatlist ()
c .UserID = from .GetUserID ()
c .Date = from .GetDate ()
if val , ok := from .GetAbout (); ok {
c .About = val
}
if val , ok := from .GetApprovedBy (); ok {
c .ApprovedBy = val
}
}
func (*ChatInviteImporter ) TypeID () uint32 {
return ChatInviteImporterTypeID
}
func (*ChatInviteImporter ) TypeName () string {
return "chatInviteImporter"
}
func (c *ChatInviteImporter ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInviteImporter" ,
ID : ChatInviteImporterTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Requested" ,
SchemaName : "requested" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "ViaChatlist" ,
SchemaName : "via_chatlist" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "About" ,
SchemaName : "about" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "ApprovedBy" ,
SchemaName : "approved_by" ,
Null : !c .Flags .Has (1 ),
},
}
return typ
}
func (c *ChatInviteImporter ) SetFlags () {
if !(c .Requested == false ) {
c .Flags .Set (0 )
}
if !(c .ViaChatlist == false ) {
c .Flags .Set (3 )
}
if !(c .About == "" ) {
c .Flags .Set (2 )
}
if !(c .ApprovedBy == 0 ) {
c .Flags .Set (1 )
}
}
func (c *ChatInviteImporter ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteImporter#8c5adfd9 as nil" )
}
b .PutID (ChatInviteImporterTypeID )
return c .EncodeBare (b )
}
func (c *ChatInviteImporter ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteImporter#8c5adfd9 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInviteImporter#8c5adfd9: field flags: %w" , err )
}
b .PutLong (c .UserID )
b .PutInt (c .Date )
if c .Flags .Has (2 ) {
b .PutString (c .About )
}
if c .Flags .Has (1 ) {
b .PutLong (c .ApprovedBy )
}
return nil
}
func (c *ChatInviteImporter ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteImporter#8c5adfd9 to nil" )
}
if err := b .ConsumeID (ChatInviteImporterTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInviteImporter ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteImporter#8c5adfd9 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: field flags: %w" , err )
}
}
c .Requested = c .Flags .Has (0 )
c .ViaChatlist = c .Flags .Has (3 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: field user_id: %w" , err )
}
c .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: field date: %w" , err )
}
c .Date = value
}
if c .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: field about: %w" , err )
}
c .About = value
}
if c .Flags .Has (1 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteImporter#8c5adfd9: field approved_by: %w" , err )
}
c .ApprovedBy = value
}
return nil
}
func (c *ChatInviteImporter ) SetRequested (value bool ) {
if value {
c .Flags .Set (0 )
c .Requested = true
} else {
c .Flags .Unset (0 )
c .Requested = false
}
}
func (c *ChatInviteImporter ) GetRequested () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChatInviteImporter ) SetViaChatlist (value bool ) {
if value {
c .Flags .Set (3 )
c .ViaChatlist = true
} else {
c .Flags .Unset (3 )
c .ViaChatlist = false
}
}
func (c *ChatInviteImporter ) GetViaChatlist () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *ChatInviteImporter ) GetUserID () (value int64 ) {
if c == nil {
return
}
return c .UserID
}
func (c *ChatInviteImporter ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *ChatInviteImporter ) SetAbout (value string ) {
c .Flags .Set (2 )
c .About = value
}
func (c *ChatInviteImporter ) GetAbout () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .About , true
}
func (c *ChatInviteImporter ) SetApprovedBy (value int64 ) {
c .Flags .Set (1 )
c .ApprovedBy = value
}
func (c *ChatInviteImporter ) GetApprovedBy () (value int64 , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .ApprovedBy , true
}
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 .