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 BotsCreateBotRequest struct {
Flags bin .Fields
ViaDeeplink bool
Name string
Username string
ManagerID InputUserClass
}
const BotsCreateBotRequestTypeID = 0xe5b17f2b
var (
_ bin .Encoder = &BotsCreateBotRequest {}
_ bin .Decoder = &BotsCreateBotRequest {}
_ bin .BareEncoder = &BotsCreateBotRequest {}
_ bin .BareDecoder = &BotsCreateBotRequest {}
)
func (c *BotsCreateBotRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .ViaDeeplink == false ) {
return false
}
if !(c .Name == "" ) {
return false
}
if !(c .Username == "" ) {
return false
}
if !(c .ManagerID == nil ) {
return false
}
return true
}
func (c *BotsCreateBotRequest ) String () string {
if c == nil {
return "BotsCreateBotRequest(nil)"
}
type Alias BotsCreateBotRequest
return fmt .Sprintf ("BotsCreateBotRequest%+v" , Alias (*c ))
}
func (c *BotsCreateBotRequest ) FillFrom (from interface {
GetViaDeeplink () (value bool )
GetName () (value string )
GetUsername () (value string )
GetManagerID () (value InputUserClass )
}) {
c .ViaDeeplink = from .GetViaDeeplink ()
c .Name = from .GetName ()
c .Username = from .GetUsername ()
c .ManagerID = from .GetManagerID ()
}
func (*BotsCreateBotRequest ) TypeID () uint32 {
return BotsCreateBotRequestTypeID
}
func (*BotsCreateBotRequest ) TypeName () string {
return "bots.createBot"
}
func (c *BotsCreateBotRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.createBot" ,
ID : BotsCreateBotRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ViaDeeplink" ,
SchemaName : "via_deeplink" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
{
Name : "ManagerID" ,
SchemaName : "manager_id" ,
},
}
return typ
}
func (c *BotsCreateBotRequest ) SetFlags () {
if !(c .ViaDeeplink == false ) {
c .Flags .Set (0 )
}
}
func (c *BotsCreateBotRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode bots.createBot#e5b17f2b as nil" )
}
b .PutID (BotsCreateBotRequestTypeID )
return c .EncodeBare (b )
}
func (c *BotsCreateBotRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode bots.createBot#e5b17f2b as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.createBot#e5b17f2b: field flags: %w" , err )
}
b .PutString (c .Name )
b .PutString (c .Username )
if c .ManagerID == nil {
return fmt .Errorf ("unable to encode bots.createBot#e5b17f2b: field manager_id is nil" )
}
if err := c .ManagerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.createBot#e5b17f2b: field manager_id: %w" , err )
}
return nil
}
func (c *BotsCreateBotRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode bots.createBot#e5b17f2b to nil" )
}
if err := b .ConsumeID (BotsCreateBotRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.createBot#e5b17f2b: %w" , err )
}
return c .DecodeBare (b )
}
func (c *BotsCreateBotRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode bots.createBot#e5b17f2b to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.createBot#e5b17f2b: field flags: %w" , err )
}
}
c .ViaDeeplink = c .Flags .Has (0 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.createBot#e5b17f2b: field name: %w" , err )
}
c .Name = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.createBot#e5b17f2b: field username: %w" , err )
}
c .Username = value
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.createBot#e5b17f2b: field manager_id: %w" , err )
}
c .ManagerID = value
}
return nil
}
func (c *BotsCreateBotRequest ) SetViaDeeplink (value bool ) {
if value {
c .Flags .Set (0 )
c .ViaDeeplink = true
} else {
c .Flags .Unset (0 )
c .ViaDeeplink = false
}
}
func (c *BotsCreateBotRequest ) GetViaDeeplink () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *BotsCreateBotRequest ) GetName () (value string ) {
if c == nil {
return
}
return c .Name
}
func (c *BotsCreateBotRequest ) GetUsername () (value string ) {
if c == nil {
return
}
return c .Username
}
func (c *BotsCreateBotRequest ) GetManagerID () (value InputUserClass ) {
if c == nil {
return
}
return c .ManagerID
}
func (c *Client ) BotsCreateBot (ctx context .Context , request *BotsCreateBotRequest ) (UserClass , error ) {
var result UserBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .User , nil
}
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 .