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 CommunitiesCreateRequest struct {
Flags bin .Fields
Hidden bool
Title string
About string
Peer InputPeerClass
}
const CommunitiesCreateRequestTypeID = 0xa63859ec
var (
_ bin .Encoder = &CommunitiesCreateRequest {}
_ bin .Decoder = &CommunitiesCreateRequest {}
_ bin .BareEncoder = &CommunitiesCreateRequest {}
_ bin .BareDecoder = &CommunitiesCreateRequest {}
)
func (c *CommunitiesCreateRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Hidden == false ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .About == "" ) {
return false
}
if !(c .Peer == nil ) {
return false
}
return true
}
func (c *CommunitiesCreateRequest ) String () string {
if c == nil {
return "CommunitiesCreateRequest(nil)"
}
type Alias CommunitiesCreateRequest
return fmt .Sprintf ("CommunitiesCreateRequest%+v" , Alias (*c ))
}
func (c *CommunitiesCreateRequest ) FillFrom (from interface {
GetHidden () (value bool )
GetTitle () (value string )
GetAbout () (value string , ok bool )
GetPeer () (value InputPeerClass )
}) {
c .Hidden = from .GetHidden ()
c .Title = from .GetTitle ()
if val , ok := from .GetAbout (); ok {
c .About = val
}
c .Peer = from .GetPeer ()
}
func (*CommunitiesCreateRequest ) TypeID () uint32 {
return CommunitiesCreateRequestTypeID
}
func (*CommunitiesCreateRequest ) TypeName () string {
return "communities.create"
}
func (c *CommunitiesCreateRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "communities.create" ,
ID : CommunitiesCreateRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hidden" ,
SchemaName : "hidden" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "About" ,
SchemaName : "about" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
}
return typ
}
func (c *CommunitiesCreateRequest ) SetFlags () {
if !(c .Hidden == false ) {
c .Flags .Set (1 )
}
if !(c .About == "" ) {
c .Flags .Set (0 )
}
}
func (c *CommunitiesCreateRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode communities.create#a63859ec as nil" )
}
b .PutID (CommunitiesCreateRequestTypeID )
return c .EncodeBare (b )
}
func (c *CommunitiesCreateRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode communities.create#a63859ec as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.create#a63859ec: field flags: %w" , err )
}
b .PutString (c .Title )
if c .Flags .Has (0 ) {
b .PutString (c .About )
}
if c .Peer == nil {
return fmt .Errorf ("unable to encode communities.create#a63859ec: field peer is nil" )
}
if err := c .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.create#a63859ec: field peer: %w" , err )
}
return nil
}
func (c *CommunitiesCreateRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode communities.create#a63859ec to nil" )
}
if err := b .ConsumeID (CommunitiesCreateRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode communities.create#a63859ec: %w" , err )
}
return c .DecodeBare (b )
}
func (c *CommunitiesCreateRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode communities.create#a63859ec to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode communities.create#a63859ec: field flags: %w" , err )
}
}
c .Hidden = c .Flags .Has (1 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode communities.create#a63859ec: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode communities.create#a63859ec: field about: %w" , err )
}
c .About = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode communities.create#a63859ec: field peer: %w" , err )
}
c .Peer = value
}
return nil
}
func (c *CommunitiesCreateRequest ) SetHidden (value bool ) {
if value {
c .Flags .Set (1 )
c .Hidden = true
} else {
c .Flags .Unset (1 )
c .Hidden = false
}
}
func (c *CommunitiesCreateRequest ) GetHidden () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *CommunitiesCreateRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *CommunitiesCreateRequest ) SetAbout (value string ) {
c .Flags .Set (0 )
c .About = value
}
func (c *CommunitiesCreateRequest ) GetAbout () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .About , true
}
func (c *CommunitiesCreateRequest ) GetPeer () (value InputPeerClass ) {
if c == nil {
return
}
return c .Peer
}
func (c *Client ) CommunitiesCreate (ctx context .Context , request *CommunitiesCreateRequest ) (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 .