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 ChannelsCheckUsernameRequest struct {
Channel InputChannelClass
Username string
}
const ChannelsCheckUsernameRequestTypeID = 0x10e6bd2c
var (
_ bin .Encoder = &ChannelsCheckUsernameRequest {}
_ bin .Decoder = &ChannelsCheckUsernameRequest {}
_ bin .BareEncoder = &ChannelsCheckUsernameRequest {}
_ bin .BareDecoder = &ChannelsCheckUsernameRequest {}
)
func (c *ChannelsCheckUsernameRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Channel == nil ) {
return false
}
if !(c .Username == "" ) {
return false
}
return true
}
func (c *ChannelsCheckUsernameRequest ) String () string {
if c == nil {
return "ChannelsCheckUsernameRequest(nil)"
}
type Alias ChannelsCheckUsernameRequest
return fmt .Sprintf ("ChannelsCheckUsernameRequest%+v" , Alias (*c ))
}
func (c *ChannelsCheckUsernameRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetUsername () (value string )
}) {
c .Channel = from .GetChannel ()
c .Username = from .GetUsername ()
}
func (*ChannelsCheckUsernameRequest ) TypeID () uint32 {
return ChannelsCheckUsernameRequestTypeID
}
func (*ChannelsCheckUsernameRequest ) TypeName () string {
return "channels.checkUsername"
}
func (c *ChannelsCheckUsernameRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.checkUsername" ,
ID : ChannelsCheckUsernameRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
}
return typ
}
func (c *ChannelsCheckUsernameRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.checkUsername#10e6bd2c as nil" )
}
b .PutID (ChannelsCheckUsernameRequestTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsCheckUsernameRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.checkUsername#10e6bd2c as nil" )
}
if c .Channel == nil {
return fmt .Errorf ("unable to encode channels.checkUsername#10e6bd2c: field channel is nil" )
}
if err := c .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.checkUsername#10e6bd2c: field channel: %w" , err )
}
b .PutString (c .Username )
return nil
}
func (c *ChannelsCheckUsernameRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.checkUsername#10e6bd2c to nil" )
}
if err := b .ConsumeID (ChannelsCheckUsernameRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.checkUsername#10e6bd2c: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsCheckUsernameRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.checkUsername#10e6bd2c to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.checkUsername#10e6bd2c: field channel: %w" , err )
}
c .Channel = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.checkUsername#10e6bd2c: field username: %w" , err )
}
c .Username = value
}
return nil
}
func (c *ChannelsCheckUsernameRequest ) GetChannel () (value InputChannelClass ) {
if c == nil {
return
}
return c .Channel
}
func (c *ChannelsCheckUsernameRequest ) GetUsername () (value string ) {
if c == nil {
return
}
return c .Username
}
func (c *ChannelsCheckUsernameRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return c .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsCheckUsername (ctx context .Context , request *ChannelsCheckUsernameRequest ) (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 .