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 BotBusinessConnection struct {
Flags bin .Fields
Disabled bool
ConnectionID string
UserID int64
DCID int
Date int
Rights BusinessBotRights
}
const BotBusinessConnectionTypeID = 0x8f34b2f5
var (
_ bin .Encoder = &BotBusinessConnection {}
_ bin .Decoder = &BotBusinessConnection {}
_ bin .BareEncoder = &BotBusinessConnection {}
_ bin .BareDecoder = &BotBusinessConnection {}
)
func (b *BotBusinessConnection ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Disabled == false ) {
return false
}
if !(b .ConnectionID == "" ) {
return false
}
if !(b .UserID == 0 ) {
return false
}
if !(b .DCID == 0 ) {
return false
}
if !(b .Date == 0 ) {
return false
}
if !(b .Rights .Zero ()) {
return false
}
return true
}
func (b *BotBusinessConnection ) String () string {
if b == nil {
return "BotBusinessConnection(nil)"
}
type Alias BotBusinessConnection
return fmt .Sprintf ("BotBusinessConnection%+v" , Alias (*b ))
}
func (b *BotBusinessConnection ) FillFrom (from interface {
GetDisabled () (value bool )
GetConnectionID () (value string )
GetUserID () (value int64 )
GetDCID () (value int )
GetDate () (value int )
GetRights () (value BusinessBotRights , ok bool )
}) {
b .Disabled = from .GetDisabled ()
b .ConnectionID = from .GetConnectionID ()
b .UserID = from .GetUserID ()
b .DCID = from .GetDCID ()
b .Date = from .GetDate ()
if val , ok := from .GetRights (); ok {
b .Rights = val
}
}
func (*BotBusinessConnection ) TypeID () uint32 {
return BotBusinessConnectionTypeID
}
func (*BotBusinessConnection ) TypeName () string {
return "botBusinessConnection"
}
func (b *BotBusinessConnection ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botBusinessConnection" ,
ID : BotBusinessConnectionTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Disabled" ,
SchemaName : "disabled" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "ConnectionID" ,
SchemaName : "connection_id" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "DCID" ,
SchemaName : "dc_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Rights" ,
SchemaName : "rights" ,
Null : !b .Flags .Has (2 ),
},
}
return typ
}
func (b *BotBusinessConnection ) SetFlags () {
if !(b .Disabled == false ) {
b .Flags .Set (1 )
}
if !(b .Rights .Zero ()) {
b .Flags .Set (2 )
}
}
func (b *BotBusinessConnection ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botBusinessConnection#8f34b2f5 as nil" )
}
buf .PutID (BotBusinessConnectionTypeID )
return b .EncodeBare (buf )
}
func (b *BotBusinessConnection ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botBusinessConnection#8f34b2f5 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botBusinessConnection#8f34b2f5: field flags: %w" , err )
}
buf .PutString (b .ConnectionID )
buf .PutLong (b .UserID )
buf .PutInt (b .DCID )
buf .PutInt (b .Date )
if b .Flags .Has (2 ) {
if err := b .Rights .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botBusinessConnection#8f34b2f5: field rights: %w" , err )
}
}
return nil
}
func (b *BotBusinessConnection ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botBusinessConnection#8f34b2f5 to nil" )
}
if err := buf .ConsumeID (BotBusinessConnectionTypeID ); err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotBusinessConnection ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botBusinessConnection#8f34b2f5 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field flags: %w" , err )
}
}
b .Disabled = b .Flags .Has (1 )
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field connection_id: %w" , err )
}
b .ConnectionID = value
}
{
value , err := buf .Long ()
if err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field user_id: %w" , err )
}
b .UserID = value
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field dc_id: %w" , err )
}
b .DCID = value
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field date: %w" , err )
}
b .Date = value
}
if b .Flags .Has (2 ) {
if err := b .Rights .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode botBusinessConnection#8f34b2f5: field rights: %w" , err )
}
}
return nil
}
func (b *BotBusinessConnection ) SetDisabled (value bool ) {
if value {
b .Flags .Set (1 )
b .Disabled = true
} else {
b .Flags .Unset (1 )
b .Disabled = false
}
}
func (b *BotBusinessConnection ) GetDisabled () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (1 )
}
func (b *BotBusinessConnection ) GetConnectionID () (value string ) {
if b == nil {
return
}
return b .ConnectionID
}
func (b *BotBusinessConnection ) GetUserID () (value int64 ) {
if b == nil {
return
}
return b .UserID
}
func (b *BotBusinessConnection ) GetDCID () (value int ) {
if b == nil {
return
}
return b .DCID
}
func (b *BotBusinessConnection ) GetDate () (value int ) {
if b == nil {
return
}
return b .Date
}
func (b *BotBusinessConnection ) SetRights (value BusinessBotRights ) {
b .Flags .Set (2 )
b .Rights = value
}
func (b *BotBusinessConnection ) GetRights () (value BusinessBotRights , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .Rights , true
}
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 .