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 ForumTopicDeleted struct {
ID int
}
const ForumTopicDeletedTypeID = 0x23f109b
func (f ForumTopicDeleted ) construct () ForumTopicClass { return &f }
var (
_ bin .Encoder = &ForumTopicDeleted {}
_ bin .Decoder = &ForumTopicDeleted {}
_ bin .BareEncoder = &ForumTopicDeleted {}
_ bin .BareDecoder = &ForumTopicDeleted {}
_ ForumTopicClass = &ForumTopicDeleted {}
)
func (f *ForumTopicDeleted ) Zero () bool {
if f == nil {
return true
}
if !(f .ID == 0 ) {
return false
}
return true
}
func (f *ForumTopicDeleted ) String () string {
if f == nil {
return "ForumTopicDeleted(nil)"
}
type Alias ForumTopicDeleted
return fmt .Sprintf ("ForumTopicDeleted%+v" , Alias (*f ))
}
func (f *ForumTopicDeleted ) FillFrom (from interface {
GetID () (value int )
}) {
f .ID = from .GetID ()
}
func (*ForumTopicDeleted ) TypeID () uint32 {
return ForumTopicDeletedTypeID
}
func (*ForumTopicDeleted ) TypeName () string {
return "forumTopicDeleted"
}
func (f *ForumTopicDeleted ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "forumTopicDeleted" ,
ID : ForumTopicDeletedTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (f *ForumTopicDeleted ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode forumTopicDeleted#23f109b as nil" )
}
b .PutID (ForumTopicDeletedTypeID )
return f .EncodeBare (b )
}
func (f *ForumTopicDeleted ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode forumTopicDeleted#23f109b as nil" )
}
b .PutInt (f .ID )
return nil
}
func (f *ForumTopicDeleted ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode forumTopicDeleted#23f109b to nil" )
}
if err := b .ConsumeID (ForumTopicDeletedTypeID ); err != nil {
return fmt .Errorf ("unable to decode forumTopicDeleted#23f109b: %w" , err )
}
return f .DecodeBare (b )
}
func (f *ForumTopicDeleted ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode forumTopicDeleted#23f109b to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopicDeleted#23f109b: field id: %w" , err )
}
f .ID = value
}
return nil
}
func (f *ForumTopicDeleted ) GetID () (value int ) {
if f == nil {
return
}
return f .ID
}
type ForumTopic struct {
Flags bin .Fields
My bool
Closed bool
Pinned bool
Short bool
Hidden bool
ID int
Date int
Title string
IconColor int
IconEmojiID int64
TopMessage int
ReadInboxMaxID int
ReadOutboxMaxID int
UnreadCount int
UnreadMentionsCount int
UnreadReactionsCount int
FromID PeerClass
NotifySettings PeerNotifySettings
Draft DraftMessageClass
}
const ForumTopicTypeID = 0x71701da9
func (f ForumTopic ) construct () ForumTopicClass { return &f }
var (
_ bin .Encoder = &ForumTopic {}
_ bin .Decoder = &ForumTopic {}
_ bin .BareEncoder = &ForumTopic {}
_ bin .BareDecoder = &ForumTopic {}
_ ForumTopicClass = &ForumTopic {}
)
func (f *ForumTopic ) Zero () bool {
if f == nil {
return true
}
if !(f .Flags .Zero ()) {
return false
}
if !(f .My == false ) {
return false
}
if !(f .Closed == false ) {
return false
}
if !(f .Pinned == false ) {
return false
}
if !(f .Short == false ) {
return false
}
if !(f .Hidden == false ) {
return false
}
if !(f .ID == 0 ) {
return false
}
if !(f .Date == 0 ) {
return false
}
if !(f .Title == "" ) {
return false
}
if !(f .IconColor == 0 ) {
return false
}
if !(f .IconEmojiID == 0 ) {
return false
}
if !(f .TopMessage == 0 ) {
return false
}
if !(f .ReadInboxMaxID == 0 ) {
return false
}
if !(f .ReadOutboxMaxID == 0 ) {
return false
}
if !(f .UnreadCount == 0 ) {
return false
}
if !(f .UnreadMentionsCount == 0 ) {
return false
}
if !(f .UnreadReactionsCount == 0 ) {
return false
}
if !(f .FromID == nil ) {
return false
}
if !(f .NotifySettings .Zero ()) {
return false
}
if !(f .Draft == nil ) {
return false
}
return true
}
func (f *ForumTopic ) String () string {
if f == nil {
return "ForumTopic(nil)"
}
type Alias ForumTopic
return fmt .Sprintf ("ForumTopic%+v" , Alias (*f ))
}
func (f *ForumTopic ) FillFrom (from interface {
GetMy () (value bool )
GetClosed () (value bool )
GetPinned () (value bool )
GetShort () (value bool )
GetHidden () (value bool )
GetID () (value int )
GetDate () (value int )
GetTitle () (value string )
GetIconColor () (value int )
GetIconEmojiID () (value int64 , ok bool )
GetTopMessage () (value int )
GetReadInboxMaxID () (value int )
GetReadOutboxMaxID () (value int )
GetUnreadCount () (value int )
GetUnreadMentionsCount () (value int )
GetUnreadReactionsCount () (value int )
GetFromID () (value PeerClass )
GetNotifySettings () (value PeerNotifySettings )
GetDraft () (value DraftMessageClass , ok bool )
}) {
f .My = from .GetMy ()
f .Closed = from .GetClosed ()
f .Pinned = from .GetPinned ()
f .Short = from .GetShort ()
f .Hidden = from .GetHidden ()
f .ID = from .GetID ()
f .Date = from .GetDate ()
f .Title = from .GetTitle ()
f .IconColor = from .GetIconColor ()
if val , ok := from .GetIconEmojiID (); ok {
f .IconEmojiID = val
}
f .TopMessage = from .GetTopMessage ()
f .ReadInboxMaxID = from .GetReadInboxMaxID ()
f .ReadOutboxMaxID = from .GetReadOutboxMaxID ()
f .UnreadCount = from .GetUnreadCount ()
f .UnreadMentionsCount = from .GetUnreadMentionsCount ()
f .UnreadReactionsCount = from .GetUnreadReactionsCount ()
f .FromID = from .GetFromID ()
f .NotifySettings = from .GetNotifySettings ()
if val , ok := from .GetDraft (); ok {
f .Draft = val
}
}
func (*ForumTopic ) TypeID () uint32 {
return ForumTopicTypeID
}
func (*ForumTopic ) TypeName () string {
return "forumTopic"
}
func (f *ForumTopic ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "forumTopic" ,
ID : ForumTopicTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "My" ,
SchemaName : "my" ,
Null : !f .Flags .Has (1 ),
},
{
Name : "Closed" ,
SchemaName : "closed" ,
Null : !f .Flags .Has (2 ),
},
{
Name : "Pinned" ,
SchemaName : "pinned" ,
Null : !f .Flags .Has (3 ),
},
{
Name : "Short" ,
SchemaName : "short" ,
Null : !f .Flags .Has (5 ),
},
{
Name : "Hidden" ,
SchemaName : "hidden" ,
Null : !f .Flags .Has (6 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "IconColor" ,
SchemaName : "icon_color" ,
},
{
Name : "IconEmojiID" ,
SchemaName : "icon_emoji_id" ,
Null : !f .Flags .Has (0 ),
},
{
Name : "TopMessage" ,
SchemaName : "top_message" ,
},
{
Name : "ReadInboxMaxID" ,
SchemaName : "read_inbox_max_id" ,
},
{
Name : "ReadOutboxMaxID" ,
SchemaName : "read_outbox_max_id" ,
},
{
Name : "UnreadCount" ,
SchemaName : "unread_count" ,
},
{
Name : "UnreadMentionsCount" ,
SchemaName : "unread_mentions_count" ,
},
{
Name : "UnreadReactionsCount" ,
SchemaName : "unread_reactions_count" ,
},
{
Name : "FromID" ,
SchemaName : "from_id" ,
},
{
Name : "NotifySettings" ,
SchemaName : "notify_settings" ,
},
{
Name : "Draft" ,
SchemaName : "draft" ,
Null : !f .Flags .Has (4 ),
},
}
return typ
}
func (f *ForumTopic ) SetFlags () {
if !(f .My == false ) {
f .Flags .Set (1 )
}
if !(f .Closed == false ) {
f .Flags .Set (2 )
}
if !(f .Pinned == false ) {
f .Flags .Set (3 )
}
if !(f .Short == false ) {
f .Flags .Set (5 )
}
if !(f .Hidden == false ) {
f .Flags .Set (6 )
}
if !(f .IconEmojiID == 0 ) {
f .Flags .Set (0 )
}
if !(f .Draft == nil ) {
f .Flags .Set (4 )
}
}
func (f *ForumTopic ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode forumTopic#71701da9 as nil" )
}
b .PutID (ForumTopicTypeID )
return f .EncodeBare (b )
}
func (f *ForumTopic ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode forumTopic#71701da9 as nil" )
}
f .SetFlags ()
if err := f .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field flags: %w" , err )
}
b .PutInt (f .ID )
b .PutInt (f .Date )
b .PutString (f .Title )
b .PutInt (f .IconColor )
if f .Flags .Has (0 ) {
b .PutLong (f .IconEmojiID )
}
b .PutInt (f .TopMessage )
b .PutInt (f .ReadInboxMaxID )
b .PutInt (f .ReadOutboxMaxID )
b .PutInt (f .UnreadCount )
b .PutInt (f .UnreadMentionsCount )
b .PutInt (f .UnreadReactionsCount )
if f .FromID == nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field from_id is nil" )
}
if err := f .FromID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field from_id: %w" , err )
}
if err := f .NotifySettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field notify_settings: %w" , err )
}
if f .Flags .Has (4 ) {
if f .Draft == nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field draft is nil" )
}
if err := f .Draft .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode forumTopic#71701da9: field draft: %w" , err )
}
}
return nil
}
func (f *ForumTopic ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode forumTopic#71701da9 to nil" )
}
if err := b .ConsumeID (ForumTopicTypeID ); err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: %w" , err )
}
return f .DecodeBare (b )
}
func (f *ForumTopic ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode forumTopic#71701da9 to nil" )
}
{
if err := f .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field flags: %w" , err )
}
}
f .My = f .Flags .Has (1 )
f .Closed = f .Flags .Has (2 )
f .Pinned = f .Flags .Has (3 )
f .Short = f .Flags .Has (5 )
f .Hidden = f .Flags .Has (6 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field id: %w" , err )
}
f .ID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field date: %w" , err )
}
f .Date = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field title: %w" , err )
}
f .Title = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field icon_color: %w" , err )
}
f .IconColor = value
}
if f .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field icon_emoji_id: %w" , err )
}
f .IconEmojiID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field top_message: %w" , err )
}
f .TopMessage = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field read_inbox_max_id: %w" , err )
}
f .ReadInboxMaxID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field read_outbox_max_id: %w" , err )
}
f .ReadOutboxMaxID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field unread_count: %w" , err )
}
f .UnreadCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field unread_mentions_count: %w" , err )
}
f .UnreadMentionsCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field unread_reactions_count: %w" , err )
}
f .UnreadReactionsCount = value
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field from_id: %w" , err )
}
f .FromID = value
}
{
if err := f .NotifySettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field notify_settings: %w" , err )
}
}
if f .Flags .Has (4 ) {
value , err := DecodeDraftMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode forumTopic#71701da9: field draft: %w" , err )
}
f .Draft = value
}
return nil
}
func (f *ForumTopic ) SetMy (value bool ) {
if value {
f .Flags .Set (1 )
f .My = true
} else {
f .Flags .Unset (1 )
f .My = false
}
}
func (f *ForumTopic ) GetMy () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (1 )
}
func (f *ForumTopic ) SetClosed (value bool ) {
if value {
f .Flags .Set (2 )
f .Closed = true
} else {
f .Flags .Unset (2 )
f .Closed = false
}
}
func (f *ForumTopic ) GetClosed () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (2 )
}
func (f *ForumTopic ) SetPinned (value bool ) {
if value {
f .Flags .Set (3 )
f .Pinned = true
} else {
f .Flags .Unset (3 )
f .Pinned = false
}
}
func (f *ForumTopic ) GetPinned () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (3 )
}
func (f *ForumTopic ) SetShort (value bool ) {
if value {
f .Flags .Set (5 )
f .Short = true
} else {
f .Flags .Unset (5 )
f .Short = false
}
}
func (f *ForumTopic ) GetShort () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (5 )
}
func (f *ForumTopic ) SetHidden (value bool ) {
if value {
f .Flags .Set (6 )
f .Hidden = true
} else {
f .Flags .Unset (6 )
f .Hidden = false
}
}
func (f *ForumTopic ) GetHidden () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (6 )
}
func (f *ForumTopic ) GetID () (value int ) {
if f == nil {
return
}
return f .ID
}
func (f *ForumTopic ) GetDate () (value int ) {
if f == nil {
return
}
return f .Date
}
func (f *ForumTopic ) GetTitle () (value string ) {
if f == nil {
return
}
return f .Title
}
func (f *ForumTopic ) GetIconColor () (value int ) {
if f == nil {
return
}
return f .IconColor
}
func (f *ForumTopic ) SetIconEmojiID (value int64 ) {
f .Flags .Set (0 )
f .IconEmojiID = value
}
func (f *ForumTopic ) GetIconEmojiID () (value int64 , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (0 ) {
return value , false
}
return f .IconEmojiID , true
}
func (f *ForumTopic ) GetTopMessage () (value int ) {
if f == nil {
return
}
return f .TopMessage
}
func (f *ForumTopic ) GetReadInboxMaxID () (value int ) {
if f == nil {
return
}
return f .ReadInboxMaxID
}
func (f *ForumTopic ) GetReadOutboxMaxID () (value int ) {
if f == nil {
return
}
return f .ReadOutboxMaxID
}
func (f *ForumTopic ) GetUnreadCount () (value int ) {
if f == nil {
return
}
return f .UnreadCount
}
func (f *ForumTopic ) GetUnreadMentionsCount () (value int ) {
if f == nil {
return
}
return f .UnreadMentionsCount
}
func (f *ForumTopic ) GetUnreadReactionsCount () (value int ) {
if f == nil {
return
}
return f .UnreadReactionsCount
}
func (f *ForumTopic ) GetFromID () (value PeerClass ) {
if f == nil {
return
}
return f .FromID
}
func (f *ForumTopic ) GetNotifySettings () (value PeerNotifySettings ) {
if f == nil {
return
}
return f .NotifySettings
}
func (f *ForumTopic ) SetDraft (value DraftMessageClass ) {
f .Flags .Set (4 )
f .Draft = value
}
func (f *ForumTopic ) GetDraft () (value DraftMessageClass , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (4 ) {
return value , false
}
return f .Draft , true
}
const ForumTopicClassName = "ForumTopic"
type ForumTopicClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ForumTopicClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int )
}
func DecodeForumTopic (buf *bin .Buffer ) (ForumTopicClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ForumTopicDeletedTypeID :
v := ForumTopicDeleted {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ForumTopicClass: %w" , err )
}
return &v , nil
case ForumTopicTypeID :
v := ForumTopic {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ForumTopicClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ForumTopicClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ForumTopicBox struct {
ForumTopic ForumTopicClass
}
func (b *ForumTopicBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ForumTopicBox to nil" )
}
v , err := DecodeForumTopic (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ForumTopic = v
return nil
}
func (b *ForumTopicBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ForumTopic == nil {
return fmt .Errorf ("unable to encode ForumTopicClass as nil" )
}
return b .ForumTopic .Encode (buf )
}
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 .