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 BotsReorderUsernamesRequest struct {
Bot InputUserClass
Order []string
}
const BotsReorderUsernamesRequestTypeID = 0x9709b1c2
var (
_ bin .Encoder = &BotsReorderUsernamesRequest {}
_ bin .Decoder = &BotsReorderUsernamesRequest {}
_ bin .BareEncoder = &BotsReorderUsernamesRequest {}
_ bin .BareDecoder = &BotsReorderUsernamesRequest {}
)
func (r *BotsReorderUsernamesRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Bot == nil ) {
return false
}
if !(r .Order == nil ) {
return false
}
return true
}
func (r *BotsReorderUsernamesRequest ) String () string {
if r == nil {
return "BotsReorderUsernamesRequest(nil)"
}
type Alias BotsReorderUsernamesRequest
return fmt .Sprintf ("BotsReorderUsernamesRequest%+v" , Alias (*r ))
}
func (r *BotsReorderUsernamesRequest ) FillFrom (from interface {
GetBot () (value InputUserClass )
GetOrder () (value []string )
}) {
r .Bot = from .GetBot ()
r .Order = from .GetOrder ()
}
func (*BotsReorderUsernamesRequest ) TypeID () uint32 {
return BotsReorderUsernamesRequestTypeID
}
func (*BotsReorderUsernamesRequest ) TypeName () string {
return "bots.reorderUsernames"
}
func (r *BotsReorderUsernamesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.reorderUsernames" ,
ID : BotsReorderUsernamesRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Order" ,
SchemaName : "order" ,
},
}
return typ
}
func (r *BotsReorderUsernamesRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode bots.reorderUsernames#9709b1c2 as nil" )
}
b .PutID (BotsReorderUsernamesRequestTypeID )
return r .EncodeBare (b )
}
func (r *BotsReorderUsernamesRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode bots.reorderUsernames#9709b1c2 as nil" )
}
if r .Bot == nil {
return fmt .Errorf ("unable to encode bots.reorderUsernames#9709b1c2: field bot is nil" )
}
if err := r .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.reorderUsernames#9709b1c2: field bot: %w" , err )
}
b .PutVectorHeader (len (r .Order ))
for _ , v := range r .Order {
b .PutString (v )
}
return nil
}
func (r *BotsReorderUsernamesRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode bots.reorderUsernames#9709b1c2 to nil" )
}
if err := b .ConsumeID (BotsReorderUsernamesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.reorderUsernames#9709b1c2: %w" , err )
}
return r .DecodeBare (b )
}
func (r *BotsReorderUsernamesRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode bots.reorderUsernames#9709b1c2 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.reorderUsernames#9709b1c2: field bot: %w" , err )
}
r .Bot = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode bots.reorderUsernames#9709b1c2: field order: %w" , err )
}
if headerLen > 0 {
r .Order = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.reorderUsernames#9709b1c2: field order: %w" , err )
}
r .Order = append (r .Order , value )
}
}
return nil
}
func (r *BotsReorderUsernamesRequest ) GetBot () (value InputUserClass ) {
if r == nil {
return
}
return r .Bot
}
func (r *BotsReorderUsernamesRequest ) GetOrder () (value []string ) {
if r == nil {
return
}
return r .Order
}
func (c *Client ) BotsReorderUsernames (ctx context .Context , request *BotsReorderUsernamesRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
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 .