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 ChannelsCreateChannelRequest struct {
Flags bin .Fields
Broadcast bool
Megagroup bool
ForImport bool
Forum bool
Title string
About string
GeoPoint InputGeoPointClass
Address string
TTLPeriod int
}
const ChannelsCreateChannelRequestTypeID = 0x91006707
var (
_ bin .Encoder = &ChannelsCreateChannelRequest {}
_ bin .Decoder = &ChannelsCreateChannelRequest {}
_ bin .BareEncoder = &ChannelsCreateChannelRequest {}
_ bin .BareDecoder = &ChannelsCreateChannelRequest {}
)
func (c *ChannelsCreateChannelRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Broadcast == false ) {
return false
}
if !(c .Megagroup == false ) {
return false
}
if !(c .ForImport == false ) {
return false
}
if !(c .Forum == false ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .About == "" ) {
return false
}
if !(c .GeoPoint == nil ) {
return false
}
if !(c .Address == "" ) {
return false
}
if !(c .TTLPeriod == 0 ) {
return false
}
return true
}
func (c *ChannelsCreateChannelRequest ) String () string {
if c == nil {
return "ChannelsCreateChannelRequest(nil)"
}
type Alias ChannelsCreateChannelRequest
return fmt .Sprintf ("ChannelsCreateChannelRequest%+v" , Alias (*c ))
}
func (c *ChannelsCreateChannelRequest ) FillFrom (from interface {
GetBroadcast () (value bool )
GetMegagroup () (value bool )
GetForImport () (value bool )
GetForum () (value bool )
GetTitle () (value string )
GetAbout () (value string )
GetGeoPoint () (value InputGeoPointClass , ok bool )
GetAddress () (value string , ok bool )
GetTTLPeriod () (value int , ok bool )
}) {
c .Broadcast = from .GetBroadcast ()
c .Megagroup = from .GetMegagroup ()
c .ForImport = from .GetForImport ()
c .Forum = from .GetForum ()
c .Title = from .GetTitle ()
c .About = from .GetAbout ()
if val , ok := from .GetGeoPoint (); ok {
c .GeoPoint = val
}
if val , ok := from .GetAddress (); ok {
c .Address = val
}
if val , ok := from .GetTTLPeriod (); ok {
c .TTLPeriod = val
}
}
func (*ChannelsCreateChannelRequest ) TypeID () uint32 {
return ChannelsCreateChannelRequestTypeID
}
func (*ChannelsCreateChannelRequest ) TypeName () string {
return "channels.createChannel"
}
func (c *ChannelsCreateChannelRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.createChannel" ,
ID : ChannelsCreateChannelRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Broadcast" ,
SchemaName : "broadcast" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Megagroup" ,
SchemaName : "megagroup" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "ForImport" ,
SchemaName : "for_import" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "Forum" ,
SchemaName : "forum" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "About" ,
SchemaName : "about" ,
},
{
Name : "GeoPoint" ,
SchemaName : "geo_point" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Address" ,
SchemaName : "address" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !c .Flags .Has (4 ),
},
}
return typ
}
func (c *ChannelsCreateChannelRequest ) SetFlags () {
if !(c .Broadcast == false ) {
c .Flags .Set (0 )
}
if !(c .Megagroup == false ) {
c .Flags .Set (1 )
}
if !(c .ForImport == false ) {
c .Flags .Set (3 )
}
if !(c .Forum == false ) {
c .Flags .Set (5 )
}
if !(c .GeoPoint == nil ) {
c .Flags .Set (2 )
}
if !(c .Address == "" ) {
c .Flags .Set (2 )
}
if !(c .TTLPeriod == 0 ) {
c .Flags .Set (4 )
}
}
func (c *ChannelsCreateChannelRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.createChannel#91006707 as nil" )
}
b .PutID (ChannelsCreateChannelRequestTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsCreateChannelRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.createChannel#91006707 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.createChannel#91006707: field flags: %w" , err )
}
b .PutString (c .Title )
b .PutString (c .About )
if c .Flags .Has (2 ) {
if c .GeoPoint == nil {
return fmt .Errorf ("unable to encode channels.createChannel#91006707: field geo_point is nil" )
}
if err := c .GeoPoint .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.createChannel#91006707: field geo_point: %w" , err )
}
}
if c .Flags .Has (2 ) {
b .PutString (c .Address )
}
if c .Flags .Has (4 ) {
b .PutInt (c .TTLPeriod )
}
return nil
}
func (c *ChannelsCreateChannelRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.createChannel#91006707 to nil" )
}
if err := b .ConsumeID (ChannelsCreateChannelRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsCreateChannelRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.createChannel#91006707 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field flags: %w" , err )
}
}
c .Broadcast = c .Flags .Has (0 )
c .Megagroup = c .Flags .Has (1 )
c .ForImport = c .Flags .Has (3 )
c .Forum = c .Flags .Has (5 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field title: %w" , err )
}
c .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field about: %w" , err )
}
c .About = value
}
if c .Flags .Has (2 ) {
value , err := DecodeInputGeoPoint (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field geo_point: %w" , err )
}
c .GeoPoint = value
}
if c .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field address: %w" , err )
}
c .Address = value
}
if c .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createChannel#91006707: field ttl_period: %w" , err )
}
c .TTLPeriod = value
}
return nil
}
func (c *ChannelsCreateChannelRequest ) SetBroadcast (value bool ) {
if value {
c .Flags .Set (0 )
c .Broadcast = true
} else {
c .Flags .Unset (0 )
c .Broadcast = false
}
}
func (c *ChannelsCreateChannelRequest ) GetBroadcast () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChannelsCreateChannelRequest ) SetMegagroup (value bool ) {
if value {
c .Flags .Set (1 )
c .Megagroup = true
} else {
c .Flags .Unset (1 )
c .Megagroup = false
}
}
func (c *ChannelsCreateChannelRequest ) GetMegagroup () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *ChannelsCreateChannelRequest ) SetForImport (value bool ) {
if value {
c .Flags .Set (3 )
c .ForImport = true
} else {
c .Flags .Unset (3 )
c .ForImport = false
}
}
func (c *ChannelsCreateChannelRequest ) GetForImport () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *ChannelsCreateChannelRequest ) SetForum (value bool ) {
if value {
c .Flags .Set (5 )
c .Forum = true
} else {
c .Flags .Unset (5 )
c .Forum = false
}
}
func (c *ChannelsCreateChannelRequest ) GetForum () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *ChannelsCreateChannelRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *ChannelsCreateChannelRequest ) GetAbout () (value string ) {
if c == nil {
return
}
return c .About
}
func (c *ChannelsCreateChannelRequest ) SetGeoPoint (value InputGeoPointClass ) {
c .Flags .Set (2 )
c .GeoPoint = value
}
func (c *ChannelsCreateChannelRequest ) GetGeoPoint () (value InputGeoPointClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .GeoPoint , true
}
func (c *ChannelsCreateChannelRequest ) SetAddress (value string ) {
c .Flags .Set (2 )
c .Address = value
}
func (c *ChannelsCreateChannelRequest ) GetAddress () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .Address , true
}
func (c *ChannelsCreateChannelRequest ) SetTTLPeriod (value int ) {
c .Flags .Set (4 )
c .TTLPeriod = value
}
func (c *ChannelsCreateChannelRequest ) GetTTLPeriod () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (4 ) {
return value , false
}
return c .TTLPeriod , true
}
func (c *ChannelsCreateChannelRequest ) GetGeoPointAsNotEmpty () (*InputGeoPoint , bool ) {
if value , ok := c .GetGeoPoint (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) ChannelsCreateChannel (ctx context .Context , request *ChannelsCreateChannelRequest ) (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.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 .