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 MessagesCreateForumTopicRequest struct {
Flags bin .Fields
TitleMissing bool
Peer InputPeerClass
Title string
IconColor int
IconEmojiID int64
RandomID int64
SendAs InputPeerClass
}
const MessagesCreateForumTopicRequestTypeID = 0x2f98c3d5
var (
_ bin .Encoder = &MessagesCreateForumTopicRequest {}
_ bin .Decoder = &MessagesCreateForumTopicRequest {}
_ bin .BareEncoder = &MessagesCreateForumTopicRequest {}
_ bin .BareDecoder = &MessagesCreateForumTopicRequest {}
)
func (c *MessagesCreateForumTopicRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .TitleMissing == false ) {
return false
}
if !(c .Peer == 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 *MessagesCreateForumTopicRequest ) String () string {
if c == nil {
return "MessagesCreateForumTopicRequest(nil)"
}
type Alias MessagesCreateForumTopicRequest
return fmt .Sprintf ("MessagesCreateForumTopicRequest%+v" , Alias (*c ))
}
func (c *MessagesCreateForumTopicRequest ) FillFrom (from interface {
GetTitleMissing () (value bool )
GetPeer () (value InputPeerClass )
GetTitle () (value string )
GetIconColor () (value int , ok bool )
GetIconEmojiID () (value int64 , ok bool )
GetRandomID () (value int64 )
GetSendAs () (value InputPeerClass , ok bool )
}) {
c .TitleMissing = from .GetTitleMissing ()
c .Peer = from .GetPeer ()
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 (*MessagesCreateForumTopicRequest ) TypeID () uint32 {
return MessagesCreateForumTopicRequestTypeID
}
func (*MessagesCreateForumTopicRequest ) TypeName () string {
return "messages.createForumTopic"
}
func (c *MessagesCreateForumTopicRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.createForumTopic" ,
ID : MessagesCreateForumTopicRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "TitleMissing" ,
SchemaName : "title_missing" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
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 *MessagesCreateForumTopicRequest ) SetFlags () {
if !(c .TitleMissing == false ) {
c .Flags .Set (4 )
}
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 *MessagesCreateForumTopicRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.createForumTopic#2f98c3d5 as nil" )
}
b .PutID (MessagesCreateForumTopicRequestTypeID )
return c .EncodeBare (b )
}
func (c *MessagesCreateForumTopicRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.createForumTopic#2f98c3d5 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.createForumTopic#2f98c3d5: field flags: %w" , err )
}
if c .Peer == nil {
return fmt .Errorf ("unable to encode messages.createForumTopic#2f98c3d5: field peer is nil" )
}
if err := c .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.createForumTopic#2f98c3d5: field peer: %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 messages.createForumTopic#2f98c3d5: field send_as is nil" )
}
if err := c .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.createForumTopic#2f98c3d5: field send_as: %w" , err )
}
}
return nil
}
func (c *MessagesCreateForumTopicRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.createForumTopic#2f98c3d5 to nil" )
}
if err := b .ConsumeID (MessagesCreateForumTopicRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.createForumTopic#2f98c3d5: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesCreateForumTopicRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.createForumTopic#2f98c3d5 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.createForumTopic#2f98c3d5: field flags: %w" , err )
}
}
c .TitleMissing = c .Flags .Has (4 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.createForumTopic#2f98c3d5: field peer: %w" , err )
}
c .Peer = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.createForumTopic#2f98c3d5: 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 messages.createForumTopic#2f98c3d5: 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 messages.createForumTopic#2f98c3d5: field icon_emoji_id: %w" , err )
}
c .IconEmojiID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.createForumTopic#2f98c3d5: 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 messages.createForumTopic#2f98c3d5: field send_as: %w" , err )
}
c .SendAs = value
}
return nil
}
func (c *MessagesCreateForumTopicRequest ) SetTitleMissing (value bool ) {
if value {
c .Flags .Set (4 )
c .TitleMissing = true
} else {
c .Flags .Unset (4 )
c .TitleMissing = false
}
}
func (c *MessagesCreateForumTopicRequest ) GetTitleMissing () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (4 )
}
func (c *MessagesCreateForumTopicRequest ) GetPeer () (value InputPeerClass ) {
if c == nil {
return
}
return c .Peer
}
func (c *MessagesCreateForumTopicRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *MessagesCreateForumTopicRequest ) SetIconColor (value int ) {
c .Flags .Set (0 )
c .IconColor = value
}
func (c *MessagesCreateForumTopicRequest ) GetIconColor () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .IconColor , true
}
func (c *MessagesCreateForumTopicRequest ) SetIconEmojiID (value int64 ) {
c .Flags .Set (3 )
c .IconEmojiID = value
}
func (c *MessagesCreateForumTopicRequest ) GetIconEmojiID () (value int64 , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .IconEmojiID , true
}
func (c *MessagesCreateForumTopicRequest ) GetRandomID () (value int64 ) {
if c == nil {
return
}
return c .RandomID
}
func (c *MessagesCreateForumTopicRequest ) SetSendAs (value InputPeerClass ) {
c .Flags .Set (2 )
c .SendAs = value
}
func (c *MessagesCreateForumTopicRequest ) GetSendAs () (value InputPeerClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .SendAs , true
}
func (c *Client ) MessagesCreateForumTopic (ctx context .Context , request *MessagesCreateForumTopicRequest ) (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 .