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 ChannelsCreateForumTopicRequest struct {
Flags bin .Fields
Channel InputChannelClass
Title string
IconColor int
IconEmojiID int64
RandomID int64
SendAs InputPeerClass
}
const ChannelsCreateForumTopicRequestTypeID = 0xf40c0224
var (
_ bin .Encoder = &ChannelsCreateForumTopicRequest {}
_ bin .Decoder = &ChannelsCreateForumTopicRequest {}
_ bin .BareEncoder = &ChannelsCreateForumTopicRequest {}
_ bin .BareDecoder = &ChannelsCreateForumTopicRequest {}
)
func (c *ChannelsCreateForumTopicRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Channel == nil ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .IconColor == 0 ) {
return false
}
if !(c .IconEmojiID == 0 ) {
return false
}
if !(c .RandomID == 0 ) {
return false
}
if !(c .SendAs == nil ) {
return false
}
return true
}
func (c *ChannelsCreateForumTopicRequest ) String () string {
if c == nil {
return "ChannelsCreateForumTopicRequest(nil)"
}
type Alias ChannelsCreateForumTopicRequest
return fmt .Sprintf ("ChannelsCreateForumTopicRequest%+v" , Alias (*c ))
}
func (c *ChannelsCreateForumTopicRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetTitle () (value string )
GetIconColor () (value int , ok bool )
GetIconEmojiID () (value int64 , ok bool )
GetRandomID () (value int64 )
GetSendAs () (value InputPeerClass , ok bool )
}) {
c .Channel = from .GetChannel ()
c .Title = from .GetTitle ()
if val , ok := from .GetIconColor (); ok {
c .IconColor = val
}
if val , ok := from .GetIconEmojiID (); ok {
c .IconEmojiID = val
}
c .RandomID = from .GetRandomID ()
if val , ok := from .GetSendAs (); ok {
c .SendAs = val
}
}
func (*ChannelsCreateForumTopicRequest ) TypeID () uint32 {
return ChannelsCreateForumTopicRequestTypeID
}
func (*ChannelsCreateForumTopicRequest ) TypeName () string {
return "channels.createForumTopic"
}
func (c *ChannelsCreateForumTopicRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.createForumTopic" ,
ID : ChannelsCreateForumTopicRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "IconColor" ,
SchemaName : "icon_color" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "IconEmojiID" ,
SchemaName : "icon_emoji_id" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "SendAs" ,
SchemaName : "send_as" ,
Null : !c .Flags .Has (2 ),
},
}
return typ
}
func (c *ChannelsCreateForumTopicRequest ) SetFlags () {
if !(c .IconColor == 0 ) {
c .Flags .Set (0 )
}
if !(c .IconEmojiID == 0 ) {
c .Flags .Set (3 )
}
if !(c .SendAs == nil ) {
c .Flags .Set (2 )
}
}
func (c *ChannelsCreateForumTopicRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.createForumTopic#f40c0224 as nil" )
}
b .PutID (ChannelsCreateForumTopicRequestTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsCreateForumTopicRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.createForumTopic#f40c0224 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.createForumTopic#f40c0224: field flags: %w" , err )
}
if c .Channel == nil {
return fmt .Errorf ("unable to encode channels.createForumTopic#f40c0224: field channel is nil" )
}
if err := c .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.createForumTopic#f40c0224: field channel: %w" , err )
}
b .PutString (c .Title )
if c .Flags .Has (0 ) {
b .PutInt (c .IconColor )
}
if c .Flags .Has (3 ) {
b .PutLong (c .IconEmojiID )
}
b .PutLong (c .RandomID )
if c .Flags .Has (2 ) {
if c .SendAs == nil {
return fmt .Errorf ("unable to encode channels.createForumTopic#f40c0224: field send_as is nil" )
}
if err := c .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.createForumTopic#f40c0224: field send_as: %w" , err )
}
}
return nil
}
func (c *ChannelsCreateForumTopicRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.createForumTopic#f40c0224 to nil" )
}
if err := b .ConsumeID (ChannelsCreateForumTopicRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsCreateForumTopicRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.createForumTopic#f40c0224 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field flags: %w" , err )
}
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field channel: %w" , err )
}
c .Channel = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field icon_color: %w" , err )
}
c .IconColor = value
}
if c .Flags .Has (3 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field icon_emoji_id: %w" , err )
}
c .IconEmojiID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field random_id: %w" , err )
}
c .RandomID = value
}
if c .Flags .Has (2 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.createForumTopic#f40c0224: field send_as: %w" , err )
}
c .SendAs = value
}
return nil
}
func (c *ChannelsCreateForumTopicRequest ) GetChannel () (value InputChannelClass ) {
if c == nil {
return
}
return c .Channel
}
func (c *ChannelsCreateForumTopicRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *ChannelsCreateForumTopicRequest ) SetIconColor (value int ) {
c .Flags .Set (0 )
c .IconColor = value
}
func (c *ChannelsCreateForumTopicRequest ) GetIconColor () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .IconColor , true
}
func (c *ChannelsCreateForumTopicRequest ) SetIconEmojiID (value int64 ) {
c .Flags .Set (3 )
c .IconEmojiID = value
}
func (c *ChannelsCreateForumTopicRequest ) GetIconEmojiID () (value int64 , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .IconEmojiID , true
}
func (c *ChannelsCreateForumTopicRequest ) GetRandomID () (value int64 ) {
if c == nil {
return
}
return c .RandomID
}
func (c *ChannelsCreateForumTopicRequest ) SetSendAs (value InputPeerClass ) {
c .Flags .Set (2 )
c .SendAs = value
}
func (c *ChannelsCreateForumTopicRequest ) GetSendAs () (value InputPeerClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .SendAs , true
}
func (c *ChannelsCreateForumTopicRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return c .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsCreateForumTopic (ctx context .Context , request *ChannelsCreateForumTopicRequest ) (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 .