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 ChannelsToggleJoinRequestRequest struct {
Flags bin .Fields
ApplyToInvites bool
Channel InputChannelClass
Enabled bool
GuardBot InputUserClass
}
const ChannelsToggleJoinRequestRequestTypeID = 0xecc2618
var (
_ bin .Encoder = &ChannelsToggleJoinRequestRequest {}
_ bin .Decoder = &ChannelsToggleJoinRequestRequest {}
_ bin .BareEncoder = &ChannelsToggleJoinRequestRequest {}
_ bin .BareDecoder = &ChannelsToggleJoinRequestRequest {}
)
func (t *ChannelsToggleJoinRequestRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .ApplyToInvites == false ) {
return false
}
if !(t .Channel == nil ) {
return false
}
if !(t .Enabled == false ) {
return false
}
if !(t .GuardBot == nil ) {
return false
}
return true
}
func (t *ChannelsToggleJoinRequestRequest ) String () string {
if t == nil {
return "ChannelsToggleJoinRequestRequest(nil)"
}
type Alias ChannelsToggleJoinRequestRequest
return fmt .Sprintf ("ChannelsToggleJoinRequestRequest%+v" , Alias (*t ))
}
func (t *ChannelsToggleJoinRequestRequest ) FillFrom (from interface {
GetApplyToInvites () (value bool )
GetChannel () (value InputChannelClass )
GetEnabled () (value bool )
GetGuardBot () (value InputUserClass , ok bool )
}) {
t .ApplyToInvites = from .GetApplyToInvites ()
t .Channel = from .GetChannel ()
t .Enabled = from .GetEnabled ()
if val , ok := from .GetGuardBot (); ok {
t .GuardBot = val
}
}
func (*ChannelsToggleJoinRequestRequest ) TypeID () uint32 {
return ChannelsToggleJoinRequestRequestTypeID
}
func (*ChannelsToggleJoinRequestRequest ) TypeName () string {
return "channels.toggleJoinRequest"
}
func (t *ChannelsToggleJoinRequestRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.toggleJoinRequest" ,
ID : ChannelsToggleJoinRequestRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ApplyToInvites" ,
SchemaName : "apply_to_invites" ,
Null : !t .Flags .Has (1 ),
},
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Enabled" ,
SchemaName : "enabled" ,
},
{
Name : "GuardBot" ,
SchemaName : "guard_bot" ,
Null : !t .Flags .Has (0 ),
},
}
return typ
}
func (t *ChannelsToggleJoinRequestRequest ) SetFlags () {
if !(t .ApplyToInvites == false ) {
t .Flags .Set (1 )
}
if !(t .GuardBot == nil ) {
t .Flags .Set (0 )
}
}
func (t *ChannelsToggleJoinRequestRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode channels.toggleJoinRequest#ecc2618 as nil" )
}
b .PutID (ChannelsToggleJoinRequestRequestTypeID )
return t .EncodeBare (b )
}
func (t *ChannelsToggleJoinRequestRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode channels.toggleJoinRequest#ecc2618 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.toggleJoinRequest#ecc2618: field flags: %w" , err )
}
if t .Channel == nil {
return fmt .Errorf ("unable to encode channels.toggleJoinRequest#ecc2618: field channel is nil" )
}
if err := t .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.toggleJoinRequest#ecc2618: field channel: %w" , err )
}
b .PutBool (t .Enabled )
if t .Flags .Has (0 ) {
if t .GuardBot == nil {
return fmt .Errorf ("unable to encode channels.toggleJoinRequest#ecc2618: field guard_bot is nil" )
}
if err := t .GuardBot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.toggleJoinRequest#ecc2618: field guard_bot: %w" , err )
}
}
return nil
}
func (t *ChannelsToggleJoinRequestRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode channels.toggleJoinRequest#ecc2618 to nil" )
}
if err := b .ConsumeID (ChannelsToggleJoinRequestRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.toggleJoinRequest#ecc2618: %w" , err )
}
return t .DecodeBare (b )
}
func (t *ChannelsToggleJoinRequestRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode channels.toggleJoinRequest#ecc2618 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channels.toggleJoinRequest#ecc2618: field flags: %w" , err )
}
}
t .ApplyToInvites = t .Flags .Has (1 )
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.toggleJoinRequest#ecc2618: field channel: %w" , err )
}
t .Channel = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode channels.toggleJoinRequest#ecc2618: field enabled: %w" , err )
}
t .Enabled = value
}
if t .Flags .Has (0 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.toggleJoinRequest#ecc2618: field guard_bot: %w" , err )
}
t .GuardBot = value
}
return nil
}
func (t *ChannelsToggleJoinRequestRequest ) SetApplyToInvites (value bool ) {
if value {
t .Flags .Set (1 )
t .ApplyToInvites = true
} else {
t .Flags .Unset (1 )
t .ApplyToInvites = false
}
}
func (t *ChannelsToggleJoinRequestRequest ) GetApplyToInvites () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (1 )
}
func (t *ChannelsToggleJoinRequestRequest ) GetChannel () (value InputChannelClass ) {
if t == nil {
return
}
return t .Channel
}
func (t *ChannelsToggleJoinRequestRequest ) GetEnabled () (value bool ) {
if t == nil {
return
}
return t .Enabled
}
func (t *ChannelsToggleJoinRequestRequest ) SetGuardBot (value InputUserClass ) {
t .Flags .Set (0 )
t .GuardBot = value
}
func (t *ChannelsToggleJoinRequestRequest ) GetGuardBot () (value InputUserClass , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (0 ) {
return value , false
}
return t .GuardBot , true
}
func (t *ChannelsToggleJoinRequestRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return t .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsToggleJoinRequest (ctx context .Context , request *ChannelsToggleJoinRequestRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .