1086 lines
24 KiB
Go
Generated
1086 lines
24 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// No-op definition for keeping imports.
|
|
var (
|
|
_ = bin.Buffer{}
|
|
_ = context.Background()
|
|
_ = fmt.Stringer(nil)
|
|
_ = strings.Builder{}
|
|
_ = errors.Is
|
|
_ = multierr.AppendInto
|
|
_ = sort.Ints
|
|
_ = tdp.Format
|
|
_ = tgerr.Error{}
|
|
_ = tdjson.Encoder{}
|
|
)
|
|
|
|
// ForumTopicDeleted represents TL type `forumTopicDeleted#23f109b`.
|
|
// Represents a deleted forum topic.
|
|
//
|
|
// See https://core.telegram.org/constructor/forumTopicDeleted for reference.
|
|
type ForumTopicDeleted struct {
|
|
// The ID of the deleted forum topic.
|
|
ID int
|
|
}
|
|
|
|
// ForumTopicDeletedTypeID is TL type id of ForumTopicDeleted.
|
|
const ForumTopicDeletedTypeID = 0x23f109b
|
|
|
|
// construct implements constructor of ForumTopicClass.
|
|
func (f ForumTopicDeleted) construct() ForumTopicClass { return &f }
|
|
|
|
// Ensuring interfaces in compile-time for ForumTopicDeleted.
|
|
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
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (f *ForumTopicDeleted) String() string {
|
|
if f == nil {
|
|
return "ForumTopicDeleted(nil)"
|
|
}
|
|
type Alias ForumTopicDeleted
|
|
return fmt.Sprintf("ForumTopicDeleted%+v", Alias(*f))
|
|
}
|
|
|
|
// FillFrom fills ForumTopicDeleted from given interface.
|
|
func (f *ForumTopicDeleted) FillFrom(from interface {
|
|
GetID() (value int)
|
|
}) {
|
|
f.ID = from.GetID()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ForumTopicDeleted) TypeID() uint32 {
|
|
return ForumTopicDeletedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ForumTopicDeleted) TypeName() string {
|
|
return "forumTopicDeleted"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
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
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
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)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
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
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
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)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
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
|
|
}
|
|
|
|
// GetID returns value of ID field.
|
|
func (f *ForumTopicDeleted) GetID() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.ID
|
|
}
|
|
|
|
// ForumTopic represents TL type `forumTopic#cdff0eca`.
|
|
// Represents a forum topic¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/forum#forum-topics
|
|
//
|
|
// See https://core.telegram.org/constructor/forumTopic for reference.
|
|
type ForumTopic struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Whether the topic was created by the current user
|
|
My bool
|
|
// Whether the topic is closed (no messages can be sent to it)
|
|
Closed bool
|
|
// Whether the topic is pinned
|
|
Pinned bool
|
|
// Whether this constructor is a reduced version of the full topic information. If set,
|
|
// only the my, closed, id, date, title, icon_color, icon_emoji_id and from_id parameters
|
|
// will contain valid information. Reduced info is usually only returned in topic-related
|
|
// admin log events »¹ and in the messages.channelMessages² constructor: if needed,
|
|
// full information can be fetched using channels.getForumTopicsByID³.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/recent-actions
|
|
// 2) https://core.telegram.org/constructor/messages.channelMessages
|
|
// 3) https://core.telegram.org/method/channels.getForumTopicsByID
|
|
Short bool
|
|
// Whether the topic is hidden (only valid for the "General" topic, id=1)
|
|
Hidden bool
|
|
// TitleMissing field of ForumTopic.
|
|
TitleMissing bool
|
|
// Topic ID¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/forum#forum-topics
|
|
ID int
|
|
// Topic creation date
|
|
Date int
|
|
// Peer field of ForumTopic.
|
|
Peer PeerClass
|
|
// Topic title
|
|
Title string
|
|
// If no custom emoji icon is specified, specifies the color of the fallback topic icon
|
|
// (RGB), one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F.
|
|
IconColor int
|
|
// ID of the custom emoji¹ used as topic icon.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/custom-emoji
|
|
//
|
|
// Use SetIconEmojiID and GetIconEmojiID helpers.
|
|
IconEmojiID int64
|
|
// ID of the last message that was sent to this topic
|
|
TopMessage int
|
|
// Position up to which all incoming messages are read.
|
|
ReadInboxMaxID int
|
|
// Position up to which all outgoing messages are read.
|
|
ReadOutboxMaxID int
|
|
// Number of unread messages
|
|
UnreadCount int
|
|
// Number of unread mentions¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/mentions
|
|
UnreadMentionsCount int
|
|
// Number of unread reactions to messages you sent
|
|
UnreadReactionsCount int
|
|
// ID of the peer that created the topic
|
|
FromID PeerClass
|
|
// Notification settings
|
|
NotifySettings PeerNotifySettings
|
|
// Message draft¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/drafts
|
|
//
|
|
// Use SetDraft and GetDraft helpers.
|
|
Draft DraftMessageClass
|
|
}
|
|
|
|
// ForumTopicTypeID is TL type id of ForumTopic.
|
|
const ForumTopicTypeID = 0xcdff0eca
|
|
|
|
// construct implements constructor of ForumTopicClass.
|
|
func (f ForumTopic) construct() ForumTopicClass { return &f }
|
|
|
|
// Ensuring interfaces in compile-time for ForumTopic.
|
|
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.TitleMissing == false) {
|
|
return false
|
|
}
|
|
if !(f.ID == 0) {
|
|
return false
|
|
}
|
|
if !(f.Date == 0) {
|
|
return false
|
|
}
|
|
if !(f.Peer == nil) {
|
|
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
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (f *ForumTopic) String() string {
|
|
if f == nil {
|
|
return "ForumTopic(nil)"
|
|
}
|
|
type Alias ForumTopic
|
|
return fmt.Sprintf("ForumTopic%+v", Alias(*f))
|
|
}
|
|
|
|
// FillFrom fills ForumTopic from given interface.
|
|
func (f *ForumTopic) FillFrom(from interface {
|
|
GetMy() (value bool)
|
|
GetClosed() (value bool)
|
|
GetPinned() (value bool)
|
|
GetShort() (value bool)
|
|
GetHidden() (value bool)
|
|
GetTitleMissing() (value bool)
|
|
GetID() (value int)
|
|
GetDate() (value int)
|
|
GetPeer() (value PeerClass)
|
|
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.TitleMissing = from.GetTitleMissing()
|
|
f.ID = from.GetID()
|
|
f.Date = from.GetDate()
|
|
f.Peer = from.GetPeer()
|
|
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
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ForumTopic) TypeID() uint32 {
|
|
return ForumTopicTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ForumTopic) TypeName() string {
|
|
return "forumTopic"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
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: "TitleMissing",
|
|
SchemaName: "title_missing",
|
|
Null: !f.Flags.Has(7),
|
|
},
|
|
{
|
|
Name: "ID",
|
|
SchemaName: "id",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
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
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
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.TitleMissing == false) {
|
|
f.Flags.Set(7)
|
|
}
|
|
if !(f.IconEmojiID == 0) {
|
|
f.Flags.Set(0)
|
|
}
|
|
if !(f.Draft == nil) {
|
|
f.Flags.Set(4)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (f *ForumTopic) Encode(b *bin.Buffer) error {
|
|
if f == nil {
|
|
return fmt.Errorf("can't encode forumTopic#cdff0eca as nil")
|
|
}
|
|
b.PutID(ForumTopicTypeID)
|
|
return f.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (f *ForumTopic) EncodeBare(b *bin.Buffer) error {
|
|
if f == nil {
|
|
return fmt.Errorf("can't encode forumTopic#cdff0eca as nil")
|
|
}
|
|
f.SetFlags()
|
|
if err := f.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field flags: %w", err)
|
|
}
|
|
b.PutInt(f.ID)
|
|
b.PutInt(f.Date)
|
|
if f.Peer == nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field peer is nil")
|
|
}
|
|
if err := f.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field peer: %w", err)
|
|
}
|
|
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#cdff0eca: field from_id is nil")
|
|
}
|
|
if err := f.FromID.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field from_id: %w", err)
|
|
}
|
|
if err := f.NotifySettings.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field notify_settings: %w", err)
|
|
}
|
|
if f.Flags.Has(4) {
|
|
if f.Draft == nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field draft is nil")
|
|
}
|
|
if err := f.Draft.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode forumTopic#cdff0eca: field draft: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (f *ForumTopic) Decode(b *bin.Buffer) error {
|
|
if f == nil {
|
|
return fmt.Errorf("can't decode forumTopic#cdff0eca to nil")
|
|
}
|
|
if err := b.ConsumeID(ForumTopicTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: %w", err)
|
|
}
|
|
return f.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (f *ForumTopic) DecodeBare(b *bin.Buffer) error {
|
|
if f == nil {
|
|
return fmt.Errorf("can't decode forumTopic#cdff0eca to nil")
|
|
}
|
|
{
|
|
if err := f.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: 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)
|
|
f.TitleMissing = f.Flags.Has(7)
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field id: %w", err)
|
|
}
|
|
f.ID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field date: %w", err)
|
|
}
|
|
f.Date = value
|
|
}
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field peer: %w", err)
|
|
}
|
|
f.Peer = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field title: %w", err)
|
|
}
|
|
f.Title = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: 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#cdff0eca: field icon_emoji_id: %w", err)
|
|
}
|
|
f.IconEmojiID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field top_message: %w", err)
|
|
}
|
|
f.TopMessage = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field read_inbox_max_id: %w", err)
|
|
}
|
|
f.ReadInboxMaxID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field read_outbox_max_id: %w", err)
|
|
}
|
|
f.ReadOutboxMaxID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field unread_count: %w", err)
|
|
}
|
|
f.UnreadCount = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field unread_mentions_count: %w", err)
|
|
}
|
|
f.UnreadMentionsCount = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field unread_reactions_count: %w", err)
|
|
}
|
|
f.UnreadReactionsCount = value
|
|
}
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field from_id: %w", err)
|
|
}
|
|
f.FromID = value
|
|
}
|
|
{
|
|
if err := f.NotifySettings.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field notify_settings: %w", err)
|
|
}
|
|
}
|
|
if f.Flags.Has(4) {
|
|
value, err := DecodeDraftMessage(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode forumTopic#cdff0eca: field draft: %w", err)
|
|
}
|
|
f.Draft = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetMy sets value of My conditional field.
|
|
func (f *ForumTopic) SetMy(value bool) {
|
|
if value {
|
|
f.Flags.Set(1)
|
|
f.My = true
|
|
} else {
|
|
f.Flags.Unset(1)
|
|
f.My = false
|
|
}
|
|
}
|
|
|
|
// GetMy returns value of My conditional field.
|
|
func (f *ForumTopic) GetMy() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(1)
|
|
}
|
|
|
|
// SetClosed sets value of Closed conditional field.
|
|
func (f *ForumTopic) SetClosed(value bool) {
|
|
if value {
|
|
f.Flags.Set(2)
|
|
f.Closed = true
|
|
} else {
|
|
f.Flags.Unset(2)
|
|
f.Closed = false
|
|
}
|
|
}
|
|
|
|
// GetClosed returns value of Closed conditional field.
|
|
func (f *ForumTopic) GetClosed() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(2)
|
|
}
|
|
|
|
// SetPinned sets value of Pinned conditional field.
|
|
func (f *ForumTopic) SetPinned(value bool) {
|
|
if value {
|
|
f.Flags.Set(3)
|
|
f.Pinned = true
|
|
} else {
|
|
f.Flags.Unset(3)
|
|
f.Pinned = false
|
|
}
|
|
}
|
|
|
|
// GetPinned returns value of Pinned conditional field.
|
|
func (f *ForumTopic) GetPinned() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(3)
|
|
}
|
|
|
|
// SetShort sets value of Short conditional field.
|
|
func (f *ForumTopic) SetShort(value bool) {
|
|
if value {
|
|
f.Flags.Set(5)
|
|
f.Short = true
|
|
} else {
|
|
f.Flags.Unset(5)
|
|
f.Short = false
|
|
}
|
|
}
|
|
|
|
// GetShort returns value of Short conditional field.
|
|
func (f *ForumTopic) GetShort() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(5)
|
|
}
|
|
|
|
// SetHidden sets value of Hidden conditional field.
|
|
func (f *ForumTopic) SetHidden(value bool) {
|
|
if value {
|
|
f.Flags.Set(6)
|
|
f.Hidden = true
|
|
} else {
|
|
f.Flags.Unset(6)
|
|
f.Hidden = false
|
|
}
|
|
}
|
|
|
|
// GetHidden returns value of Hidden conditional field.
|
|
func (f *ForumTopic) GetHidden() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(6)
|
|
}
|
|
|
|
// SetTitleMissing sets value of TitleMissing conditional field.
|
|
func (f *ForumTopic) SetTitleMissing(value bool) {
|
|
if value {
|
|
f.Flags.Set(7)
|
|
f.TitleMissing = true
|
|
} else {
|
|
f.Flags.Unset(7)
|
|
f.TitleMissing = false
|
|
}
|
|
}
|
|
|
|
// GetTitleMissing returns value of TitleMissing conditional field.
|
|
func (f *ForumTopic) GetTitleMissing() (value bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Flags.Has(7)
|
|
}
|
|
|
|
// GetID returns value of ID field.
|
|
func (f *ForumTopic) GetID() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.ID
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (f *ForumTopic) GetDate() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Date
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (f *ForumTopic) GetPeer() (value PeerClass) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Peer
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (f *ForumTopic) GetTitle() (value string) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.Title
|
|
}
|
|
|
|
// GetIconColor returns value of IconColor field.
|
|
func (f *ForumTopic) GetIconColor() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.IconColor
|
|
}
|
|
|
|
// SetIconEmojiID sets value of IconEmojiID conditional field.
|
|
func (f *ForumTopic) SetIconEmojiID(value int64) {
|
|
f.Flags.Set(0)
|
|
f.IconEmojiID = value
|
|
}
|
|
|
|
// GetIconEmojiID returns value of IconEmojiID conditional field and
|
|
// boolean which is true if field was set.
|
|
func (f *ForumTopic) GetIconEmojiID() (value int64, ok bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
if !f.Flags.Has(0) {
|
|
return value, false
|
|
}
|
|
return f.IconEmojiID, true
|
|
}
|
|
|
|
// GetTopMessage returns value of TopMessage field.
|
|
func (f *ForumTopic) GetTopMessage() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.TopMessage
|
|
}
|
|
|
|
// GetReadInboxMaxID returns value of ReadInboxMaxID field.
|
|
func (f *ForumTopic) GetReadInboxMaxID() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.ReadInboxMaxID
|
|
}
|
|
|
|
// GetReadOutboxMaxID returns value of ReadOutboxMaxID field.
|
|
func (f *ForumTopic) GetReadOutboxMaxID() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.ReadOutboxMaxID
|
|
}
|
|
|
|
// GetUnreadCount returns value of UnreadCount field.
|
|
func (f *ForumTopic) GetUnreadCount() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.UnreadCount
|
|
}
|
|
|
|
// GetUnreadMentionsCount returns value of UnreadMentionsCount field.
|
|
func (f *ForumTopic) GetUnreadMentionsCount() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.UnreadMentionsCount
|
|
}
|
|
|
|
// GetUnreadReactionsCount returns value of UnreadReactionsCount field.
|
|
func (f *ForumTopic) GetUnreadReactionsCount() (value int) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.UnreadReactionsCount
|
|
}
|
|
|
|
// GetFromID returns value of FromID field.
|
|
func (f *ForumTopic) GetFromID() (value PeerClass) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.FromID
|
|
}
|
|
|
|
// GetNotifySettings returns value of NotifySettings field.
|
|
func (f *ForumTopic) GetNotifySettings() (value PeerNotifySettings) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
return f.NotifySettings
|
|
}
|
|
|
|
// SetDraft sets value of Draft conditional field.
|
|
func (f *ForumTopic) SetDraft(value DraftMessageClass) {
|
|
f.Flags.Set(4)
|
|
f.Draft = value
|
|
}
|
|
|
|
// GetDraft returns value of Draft conditional field and
|
|
// boolean which is true if field was set.
|
|
func (f *ForumTopic) GetDraft() (value DraftMessageClass, ok bool) {
|
|
if f == nil {
|
|
return
|
|
}
|
|
if !f.Flags.Has(4) {
|
|
return value, false
|
|
}
|
|
return f.Draft, true
|
|
}
|
|
|
|
// ForumTopicClassName is schema name of ForumTopicClass.
|
|
const ForumTopicClassName = "ForumTopic"
|
|
|
|
// ForumTopicClass represents ForumTopic generic type.
|
|
//
|
|
// See https://core.telegram.org/type/ForumTopic for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeForumTopic(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.ForumTopicDeleted: // forumTopicDeleted#23f109b
|
|
// case *tg.ForumTopic: // forumTopic#cdff0eca
|
|
// default: panic(v)
|
|
// }
|
|
type ForumTopicClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() ForumTopicClass
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
TypeID() uint32
|
|
// TypeName returns name of type in TL schema.
|
|
TypeName() string
|
|
// String implements fmt.Stringer.
|
|
String() string
|
|
// Zero returns true if current object has a zero value.
|
|
Zero() bool
|
|
|
|
// The ID of the deleted forum topic.
|
|
GetID() (value int)
|
|
}
|
|
|
|
// DecodeForumTopic implements binary de-serialization for ForumTopicClass.
|
|
func DecodeForumTopic(buf *bin.Buffer) (ForumTopicClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case ForumTopicDeletedTypeID:
|
|
// Decoding forumTopicDeleted#23f109b.
|
|
v := ForumTopicDeleted{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ForumTopicClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ForumTopicTypeID:
|
|
// Decoding forumTopic#cdff0eca.
|
|
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))
|
|
}
|
|
}
|
|
|
|
// ForumTopic boxes the ForumTopicClass providing a helper.
|
|
type ForumTopicBox struct {
|
|
ForumTopic ForumTopicClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for ForumTopicBox.
|
|
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
|
|
}
|
|
|
|
// Encode implements bin.Encode for ForumTopicBox.
|
|
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)
|
|
}
|