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 BotsSetCustomVerificationRequest struct {
Flags bin .Fields
Enabled bool
Bot InputUserClass
Peer InputPeerClass
CustomDescription string
}
const BotsSetCustomVerificationRequestTypeID = 0x8b89dfbd
var (
_ bin .Encoder = &BotsSetCustomVerificationRequest {}
_ bin .Decoder = &BotsSetCustomVerificationRequest {}
_ bin .BareEncoder = &BotsSetCustomVerificationRequest {}
_ bin .BareDecoder = &BotsSetCustomVerificationRequest {}
)
func (s *BotsSetCustomVerificationRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Enabled == false ) {
return false
}
if !(s .Bot == nil ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .CustomDescription == "" ) {
return false
}
return true
}
func (s *BotsSetCustomVerificationRequest ) String () string {
if s == nil {
return "BotsSetCustomVerificationRequest(nil)"
}
type Alias BotsSetCustomVerificationRequest
return fmt .Sprintf ("BotsSetCustomVerificationRequest%+v" , Alias (*s ))
}
func (s *BotsSetCustomVerificationRequest ) FillFrom (from interface {
GetEnabled () (value bool )
GetBot () (value InputUserClass , ok bool )
GetPeer () (value InputPeerClass )
GetCustomDescription () (value string , ok bool )
}) {
s .Enabled = from .GetEnabled ()
if val , ok := from .GetBot (); ok {
s .Bot = val
}
s .Peer = from .GetPeer ()
if val , ok := from .GetCustomDescription (); ok {
s .CustomDescription = val
}
}
func (*BotsSetCustomVerificationRequest ) TypeID () uint32 {
return BotsSetCustomVerificationRequestTypeID
}
func (*BotsSetCustomVerificationRequest ) TypeName () string {
return "bots.setCustomVerification"
}
func (s *BotsSetCustomVerificationRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.setCustomVerification" ,
ID : BotsSetCustomVerificationRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Enabled" ,
SchemaName : "enabled" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "CustomDescription" ,
SchemaName : "custom_description" ,
Null : !s .Flags .Has (2 ),
},
}
return typ
}
func (s *BotsSetCustomVerificationRequest ) SetFlags () {
if !(s .Enabled == false ) {
s .Flags .Set (1 )
}
if !(s .Bot == nil ) {
s .Flags .Set (0 )
}
if !(s .CustomDescription == "" ) {
s .Flags .Set (2 )
}
}
func (s *BotsSetCustomVerificationRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode bots.setCustomVerification#8b89dfbd as nil" )
}
b .PutID (BotsSetCustomVerificationRequestTypeID )
return s .EncodeBare (b )
}
func (s *BotsSetCustomVerificationRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode bots.setCustomVerification#8b89dfbd as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.setCustomVerification#8b89dfbd: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
if s .Bot == nil {
return fmt .Errorf ("unable to encode bots.setCustomVerification#8b89dfbd: field bot is nil" )
}
if err := s .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.setCustomVerification#8b89dfbd: field bot: %w" , err )
}
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode bots.setCustomVerification#8b89dfbd: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.setCustomVerification#8b89dfbd: field peer: %w" , err )
}
if s .Flags .Has (2 ) {
b .PutString (s .CustomDescription )
}
return nil
}
func (s *BotsSetCustomVerificationRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode bots.setCustomVerification#8b89dfbd to nil" )
}
if err := b .ConsumeID (BotsSetCustomVerificationRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.setCustomVerification#8b89dfbd: %w" , err )
}
return s .DecodeBare (b )
}
func (s *BotsSetCustomVerificationRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode bots.setCustomVerification#8b89dfbd to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.setCustomVerification#8b89dfbd: field flags: %w" , err )
}
}
s .Enabled = s .Flags .Has (1 )
if s .Flags .Has (0 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.setCustomVerification#8b89dfbd: field bot: %w" , err )
}
s .Bot = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.setCustomVerification#8b89dfbd: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.setCustomVerification#8b89dfbd: field custom_description: %w" , err )
}
s .CustomDescription = value
}
return nil
}
func (s *BotsSetCustomVerificationRequest ) SetEnabled (value bool ) {
if value {
s .Flags .Set (1 )
s .Enabled = true
} else {
s .Flags .Unset (1 )
s .Enabled = false
}
}
func (s *BotsSetCustomVerificationRequest ) GetEnabled () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *BotsSetCustomVerificationRequest ) SetBot (value InputUserClass ) {
s .Flags .Set (0 )
s .Bot = value
}
func (s *BotsSetCustomVerificationRequest ) GetBot () (value InputUserClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Bot , true
}
func (s *BotsSetCustomVerificationRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *BotsSetCustomVerificationRequest ) SetCustomDescription (value string ) {
s .Flags .Set (2 )
s .CustomDescription = value
}
func (s *BotsSetCustomVerificationRequest ) GetCustomDescription () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .CustomDescription , true
}
func (c *Client ) BotsSetCustomVerification (ctx context .Context , request *BotsSetCustomVerificationRequest ) (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.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 .