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 BotsAddUsernameRequest struct {
Bot InputUserClass
Username string
}
const BotsAddUsernameRequestTypeID = 0x3501c08a
var (
_ bin .Encoder = &BotsAddUsernameRequest {}
_ bin .Decoder = &BotsAddUsernameRequest {}
_ bin .BareEncoder = &BotsAddUsernameRequest {}
_ bin .BareDecoder = &BotsAddUsernameRequest {}
)
func (a *BotsAddUsernameRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .Bot == nil ) {
return false
}
if !(a .Username == "" ) {
return false
}
return true
}
func (a *BotsAddUsernameRequest ) String () string {
if a == nil {
return "BotsAddUsernameRequest(nil)"
}
type Alias BotsAddUsernameRequest
return fmt .Sprintf ("BotsAddUsernameRequest%+v" , Alias (*a ))
}
func (a *BotsAddUsernameRequest ) FillFrom (from interface {
GetBot () (value InputUserClass )
GetUsername () (value string )
}) {
a .Bot = from .GetBot ()
a .Username = from .GetUsername ()
}
func (*BotsAddUsernameRequest ) TypeID () uint32 {
return BotsAddUsernameRequestTypeID
}
func (*BotsAddUsernameRequest ) TypeName () string {
return "bots.addUsername"
}
func (a *BotsAddUsernameRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.addUsername" ,
ID : BotsAddUsernameRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
}
return typ
}
func (a *BotsAddUsernameRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode bots.addUsername#3501c08a as nil" )
}
b .PutID (BotsAddUsernameRequestTypeID )
return a .EncodeBare (b )
}
func (a *BotsAddUsernameRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode bots.addUsername#3501c08a as nil" )
}
if a .Bot == nil {
return fmt .Errorf ("unable to encode bots.addUsername#3501c08a: field bot is nil" )
}
if err := a .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.addUsername#3501c08a: field bot: %w" , err )
}
b .PutString (a .Username )
return nil
}
func (a *BotsAddUsernameRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode bots.addUsername#3501c08a to nil" )
}
if err := b .ConsumeID (BotsAddUsernameRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.addUsername#3501c08a: %w" , err )
}
return a .DecodeBare (b )
}
func (a *BotsAddUsernameRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode bots.addUsername#3501c08a to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.addUsername#3501c08a: field bot: %w" , err )
}
a .Bot = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.addUsername#3501c08a: field username: %w" , err )
}
a .Username = value
}
return nil
}
func (a *BotsAddUsernameRequest ) GetBot () (value InputUserClass ) {
if a == nil {
return
}
return a .Bot
}
func (a *BotsAddUsernameRequest ) GetUsername () (value string ) {
if a == nil {
return
}
return a .Username
}
func (c *Client ) BotsAddUsername (ctx context .Context , request *BotsAddUsernameRequest ) (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.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .