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 ConnectedBot struct {
Flags bin .Fields
BotID int64
Recipients BusinessBotRecipients
Rights BusinessBotRights
Device string
Date int
Location string
}
const ConnectedBotTypeID = 0x33ed001
var (
_ bin .Encoder = &ConnectedBot {}
_ bin .Decoder = &ConnectedBot {}
_ bin .BareEncoder = &ConnectedBot {}
_ bin .BareDecoder = &ConnectedBot {}
)
func (c *ConnectedBot ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .BotID == 0 ) {
return false
}
if !(c .Recipients .Zero ()) {
return false
}
if !(c .Rights .Zero ()) {
return false
}
if !(c .Device == "" ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .Location == "" ) {
return false
}
return true
}
func (c *ConnectedBot ) String () string {
if c == nil {
return "ConnectedBot(nil)"
}
type Alias ConnectedBot
return fmt .Sprintf ("ConnectedBot%+v" , Alias (*c ))
}
func (c *ConnectedBot ) FillFrom (from interface {
GetBotID () (value int64 )
GetRecipients () (value BusinessBotRecipients )
GetRights () (value BusinessBotRights )
GetDevice () (value string , ok bool )
GetDate () (value int , ok bool )
GetLocation () (value string , ok bool )
}) {
c .BotID = from .GetBotID ()
c .Recipients = from .GetRecipients ()
c .Rights = from .GetRights ()
if val , ok := from .GetDevice (); ok {
c .Device = val
}
if val , ok := from .GetDate (); ok {
c .Date = val
}
if val , ok := from .GetLocation (); ok {
c .Location = val
}
}
func (*ConnectedBot ) TypeID () uint32 {
return ConnectedBotTypeID
}
func (*ConnectedBot ) TypeName () string {
return "connectedBot"
}
func (c *ConnectedBot ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "connectedBot" ,
ID : ConnectedBotTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "Recipients" ,
SchemaName : "recipients" ,
},
{
Name : "Rights" ,
SchemaName : "rights" ,
},
{
Name : "Device" ,
SchemaName : "device" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Location" ,
SchemaName : "location" ,
Null : !c .Flags .Has (2 ),
},
}
return typ
}
func (c *ConnectedBot ) SetFlags () {
if !(c .Device == "" ) {
c .Flags .Set (0 )
}
if !(c .Date == 0 ) {
c .Flags .Set (1 )
}
if !(c .Location == "" ) {
c .Flags .Set (2 )
}
}
func (c *ConnectedBot ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode connectedBot#33ed001 as nil" )
}
b .PutID (ConnectedBotTypeID )
return c .EncodeBare (b )
}
func (c *ConnectedBot ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode connectedBot#33ed001 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode connectedBot#33ed001: field flags: %w" , err )
}
b .PutLong (c .BotID )
if err := c .Recipients .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode connectedBot#33ed001: field recipients: %w" , err )
}
if err := c .Rights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode connectedBot#33ed001: field rights: %w" , err )
}
if c .Flags .Has (0 ) {
b .PutString (c .Device )
}
if c .Flags .Has (1 ) {
b .PutInt (c .Date )
}
if c .Flags .Has (2 ) {
b .PutString (c .Location )
}
return nil
}
func (c *ConnectedBot ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode connectedBot#33ed001 to nil" )
}
if err := b .ConsumeID (ConnectedBotTypeID ); err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ConnectedBot ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode connectedBot#33ed001 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: field bot_id: %w" , err )
}
c .BotID = value
}
{
if err := c .Recipients .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: field recipients: %w" , err )
}
}
{
if err := c .Rights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: field rights: %w" , err )
}
}
if c .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: field device: %w" , err )
}
c .Device = value
}
if c .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode connectedBot#33ed001: 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 connectedBot#33ed001: field location: %w" , err )
}
c .Location = value
}
return nil
}
func (c *ConnectedBot ) GetBotID () (value int64 ) {
if c == nil {
return
}
return c .BotID
}
func (c *ConnectedBot ) GetRecipients () (value BusinessBotRecipients ) {
if c == nil {
return
}
return c .Recipients
}
func (c *ConnectedBot ) GetRights () (value BusinessBotRights ) {
if c == nil {
return
}
return c .Rights
}
func (c *ConnectedBot ) SetDevice (value string ) {
c .Flags .Set (0 )
c .Device = value
}
func (c *ConnectedBot ) GetDevice () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .Device , true
}
func (c *ConnectedBot ) SetDate (value int ) {
c .Flags .Set (1 )
c .Date = value
}
func (c *ConnectedBot ) GetDate () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .Date , true
}
func (c *ConnectedBot ) SetLocation (value string ) {
c .Flags .Set (2 )
c .Location = value
}
func (c *ConnectedBot ) GetLocation () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .Location , 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 .