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 CommunitiesToggleParticipantBannedRequest struct {
Flags bin .Fields
Unban bool
Community InputChannelClass
Participant InputPeerClass
}
const CommunitiesToggleParticipantBannedRequestTypeID = 0x9967ad0f
var (
_ bin .Encoder = &CommunitiesToggleParticipantBannedRequest {}
_ bin .Decoder = &CommunitiesToggleParticipantBannedRequest {}
_ bin .BareEncoder = &CommunitiesToggleParticipantBannedRequest {}
_ bin .BareDecoder = &CommunitiesToggleParticipantBannedRequest {}
)
func (t *CommunitiesToggleParticipantBannedRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .Unban == false ) {
return false
}
if !(t .Community == nil ) {
return false
}
if !(t .Participant == nil ) {
return false
}
return true
}
func (t *CommunitiesToggleParticipantBannedRequest ) String () string {
if t == nil {
return "CommunitiesToggleParticipantBannedRequest(nil)"
}
type Alias CommunitiesToggleParticipantBannedRequest
return fmt .Sprintf ("CommunitiesToggleParticipantBannedRequest%+v" , Alias (*t ))
}
func (t *CommunitiesToggleParticipantBannedRequest ) FillFrom (from interface {
GetUnban () (value bool )
GetCommunity () (value InputChannelClass )
GetParticipant () (value InputPeerClass )
}) {
t .Unban = from .GetUnban ()
t .Community = from .GetCommunity ()
t .Participant = from .GetParticipant ()
}
func (*CommunitiesToggleParticipantBannedRequest ) TypeID () uint32 {
return CommunitiesToggleParticipantBannedRequestTypeID
}
func (*CommunitiesToggleParticipantBannedRequest ) TypeName () string {
return "communities.toggleParticipantBanned"
}
func (t *CommunitiesToggleParticipantBannedRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "communities.toggleParticipantBanned" ,
ID : CommunitiesToggleParticipantBannedRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Unban" ,
SchemaName : "unban" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Community" ,
SchemaName : "community" ,
},
{
Name : "Participant" ,
SchemaName : "participant" ,
},
}
return typ
}
func (t *CommunitiesToggleParticipantBannedRequest ) SetFlags () {
if !(t .Unban == false ) {
t .Flags .Set (0 )
}
}
func (t *CommunitiesToggleParticipantBannedRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode communities.toggleParticipantBanned#9967ad0f as nil" )
}
b .PutID (CommunitiesToggleParticipantBannedRequestTypeID )
return t .EncodeBare (b )
}
func (t *CommunitiesToggleParticipantBannedRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode communities.toggleParticipantBanned#9967ad0f as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.toggleParticipantBanned#9967ad0f: field flags: %w" , err )
}
if t .Community == nil {
return fmt .Errorf ("unable to encode communities.toggleParticipantBanned#9967ad0f: field community is nil" )
}
if err := t .Community .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.toggleParticipantBanned#9967ad0f: field community: %w" , err )
}
if t .Participant == nil {
return fmt .Errorf ("unable to encode communities.toggleParticipantBanned#9967ad0f: field participant is nil" )
}
if err := t .Participant .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.toggleParticipantBanned#9967ad0f: field participant: %w" , err )
}
return nil
}
func (t *CommunitiesToggleParticipantBannedRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode communities.toggleParticipantBanned#9967ad0f to nil" )
}
if err := b .ConsumeID (CommunitiesToggleParticipantBannedRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode communities.toggleParticipantBanned#9967ad0f: %w" , err )
}
return t .DecodeBare (b )
}
func (t *CommunitiesToggleParticipantBannedRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode communities.toggleParticipantBanned#9967ad0f to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode communities.toggleParticipantBanned#9967ad0f: field flags: %w" , err )
}
}
t .Unban = t .Flags .Has (0 )
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode communities.toggleParticipantBanned#9967ad0f: field community: %w" , err )
}
t .Community = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode communities.toggleParticipantBanned#9967ad0f: field participant: %w" , err )
}
t .Participant = value
}
return nil
}
func (t *CommunitiesToggleParticipantBannedRequest ) SetUnban (value bool ) {
if value {
t .Flags .Set (0 )
t .Unban = true
} else {
t .Flags .Unset (0 )
t .Unban = false
}
}
func (t *CommunitiesToggleParticipantBannedRequest ) GetUnban () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (0 )
}
func (t *CommunitiesToggleParticipantBannedRequest ) GetCommunity () (value InputChannelClass ) {
if t == nil {
return
}
return t .Community
}
func (t *CommunitiesToggleParticipantBannedRequest ) GetParticipant () (value InputPeerClass ) {
if t == nil {
return
}
return t .Participant
}
func (t *CommunitiesToggleParticipantBannedRequest ) GetCommunityAsNotEmpty () (NotEmptyInputChannel , bool ) {
return t .Community .AsNotEmpty ()
}
func (c *Client ) CommunitiesToggleParticipantBanned (ctx context .Context , request *CommunitiesToggleParticipantBannedRequest ) (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 .