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 BotsToggleUsernameRequest struct {
Bot InputUserClass
Username string
Active bool
}
const BotsToggleUsernameRequestTypeID = 0x53ca973
var (
_ bin .Encoder = &BotsToggleUsernameRequest {}
_ bin .Decoder = &BotsToggleUsernameRequest {}
_ bin .BareEncoder = &BotsToggleUsernameRequest {}
_ bin .BareDecoder = &BotsToggleUsernameRequest {}
)
func (t *BotsToggleUsernameRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Bot == nil ) {
return false
}
if !(t .Username == "" ) {
return false
}
if !(t .Active == false ) {
return false
}
return true
}
func (t *BotsToggleUsernameRequest ) String () string {
if t == nil {
return "BotsToggleUsernameRequest(nil)"
}
type Alias BotsToggleUsernameRequest
return fmt .Sprintf ("BotsToggleUsernameRequest%+v" , Alias (*t ))
}
func (t *BotsToggleUsernameRequest ) FillFrom (from interface {
GetBot () (value InputUserClass )
GetUsername () (value string )
GetActive () (value bool )
}) {
t .Bot = from .GetBot ()
t .Username = from .GetUsername ()
t .Active = from .GetActive ()
}
func (*BotsToggleUsernameRequest ) TypeID () uint32 {
return BotsToggleUsernameRequestTypeID
}
func (*BotsToggleUsernameRequest ) TypeName () string {
return "bots.toggleUsername"
}
func (t *BotsToggleUsernameRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.toggleUsername" ,
ID : BotsToggleUsernameRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
{
Name : "Active" ,
SchemaName : "active" ,
},
}
return typ
}
func (t *BotsToggleUsernameRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode bots.toggleUsername#53ca973 as nil" )
}
b .PutID (BotsToggleUsernameRequestTypeID )
return t .EncodeBare (b )
}
func (t *BotsToggleUsernameRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode bots.toggleUsername#53ca973 as nil" )
}
if t .Bot == nil {
return fmt .Errorf ("unable to encode bots.toggleUsername#53ca973: field bot is nil" )
}
if err := t .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.toggleUsername#53ca973: field bot: %w" , err )
}
b .PutString (t .Username )
b .PutBool (t .Active )
return nil
}
func (t *BotsToggleUsernameRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode bots.toggleUsername#53ca973 to nil" )
}
if err := b .ConsumeID (BotsToggleUsernameRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.toggleUsername#53ca973: %w" , err )
}
return t .DecodeBare (b )
}
func (t *BotsToggleUsernameRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode bots.toggleUsername#53ca973 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.toggleUsername#53ca973: field bot: %w" , err )
}
t .Bot = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.toggleUsername#53ca973: field username: %w" , err )
}
t .Username = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode bots.toggleUsername#53ca973: field active: %w" , err )
}
t .Active = value
}
return nil
}
func (t *BotsToggleUsernameRequest ) GetBot () (value InputUserClass ) {
if t == nil {
return
}
return t .Bot
}
func (t *BotsToggleUsernameRequest ) GetUsername () (value string ) {
if t == nil {
return
}
return t .Username
}
func (t *BotsToggleUsernameRequest ) GetActive () (value bool ) {
if t == nil {
return
}
return t .Active
}
func (c *Client ) BotsToggleUsername (ctx context .Context , request *BotsToggleUsernameRequest ) (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 .