7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
365 lines
8.4 KiB
Go
365 lines
8.4 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tdapi
|
|
|
|
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{}
|
|
)
|
|
|
|
// ChatFolderInfo represents TL type `chatFolderInfo#309c140d`.
|
|
type ChatFolderInfo struct {
|
|
// Unique chat folder identifier
|
|
ID int32
|
|
// The name of the folder
|
|
Name ChatFolderName
|
|
// The chosen or default icon for the chat folder
|
|
Icon ChatFolderIcon
|
|
// The identifier of the chosen color for the chat folder icon; from -1 to 6. If -1, then
|
|
// color is disabled
|
|
ColorID int32
|
|
// True, if at least one link has been created for the folder
|
|
IsShareable bool
|
|
// True, if the chat folder has invite links created by the current user
|
|
HasMyInviteLinks bool
|
|
}
|
|
|
|
// ChatFolderInfoTypeID is TL type id of ChatFolderInfo.
|
|
const ChatFolderInfoTypeID = 0x309c140d
|
|
|
|
// Ensuring interfaces in compile-time for ChatFolderInfo.
|
|
var (
|
|
_ bin.Encoder = &ChatFolderInfo{}
|
|
_ bin.Decoder = &ChatFolderInfo{}
|
|
_ bin.BareEncoder = &ChatFolderInfo{}
|
|
_ bin.BareDecoder = &ChatFolderInfo{}
|
|
)
|
|
|
|
func (c *ChatFolderInfo) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.ID == 0) {
|
|
return false
|
|
}
|
|
if !(c.Name.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Icon.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.ColorID == 0) {
|
|
return false
|
|
}
|
|
if !(c.IsShareable == false) {
|
|
return false
|
|
}
|
|
if !(c.HasMyInviteLinks == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChatFolderInfo) String() string {
|
|
if c == nil {
|
|
return "ChatFolderInfo(nil)"
|
|
}
|
|
type Alias ChatFolderInfo
|
|
return fmt.Sprintf("ChatFolderInfo%+v", Alias(*c))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChatFolderInfo) TypeID() uint32 {
|
|
return ChatFolderInfoTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChatFolderInfo) TypeName() string {
|
|
return "chatFolderInfo"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChatFolderInfo) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "chatFolderInfo",
|
|
ID: ChatFolderInfoTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ID",
|
|
SchemaName: "id",
|
|
},
|
|
{
|
|
Name: "Name",
|
|
SchemaName: "name",
|
|
},
|
|
{
|
|
Name: "Icon",
|
|
SchemaName: "icon",
|
|
},
|
|
{
|
|
Name: "ColorID",
|
|
SchemaName: "color_id",
|
|
},
|
|
{
|
|
Name: "IsShareable",
|
|
SchemaName: "is_shareable",
|
|
},
|
|
{
|
|
Name: "HasMyInviteLinks",
|
|
SchemaName: "has_my_invite_links",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChatFolderInfo) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatFolderInfo#309c140d as nil")
|
|
}
|
|
b.PutID(ChatFolderInfoTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChatFolderInfo) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatFolderInfo#309c140d as nil")
|
|
}
|
|
b.PutInt32(c.ID)
|
|
if err := c.Name.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode chatFolderInfo#309c140d: field name: %w", err)
|
|
}
|
|
if err := c.Icon.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode chatFolderInfo#309c140d: field icon: %w", err)
|
|
}
|
|
b.PutInt32(c.ColorID)
|
|
b.PutBool(c.IsShareable)
|
|
b.PutBool(c.HasMyInviteLinks)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChatFolderInfo) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatFolderInfo#309c140d to nil")
|
|
}
|
|
if err := b.ConsumeID(ChatFolderInfoTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChatFolderInfo) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatFolderInfo#309c140d to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field id: %w", err)
|
|
}
|
|
c.ID = value
|
|
}
|
|
{
|
|
if err := c.Name.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field name: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := c.Icon.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field icon: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field color_id: %w", err)
|
|
}
|
|
c.ColorID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field is_shareable: %w", err)
|
|
}
|
|
c.IsShareable = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field has_my_invite_links: %w", err)
|
|
}
|
|
c.HasMyInviteLinks = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (c *ChatFolderInfo) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatFolderInfo#309c140d as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("chatFolderInfo")
|
|
b.Comma()
|
|
b.FieldStart("id")
|
|
b.PutInt32(c.ID)
|
|
b.Comma()
|
|
b.FieldStart("name")
|
|
if err := c.Name.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode chatFolderInfo#309c140d: field name: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("icon")
|
|
if err := c.Icon.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode chatFolderInfo#309c140d: field icon: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("color_id")
|
|
b.PutInt32(c.ColorID)
|
|
b.Comma()
|
|
b.FieldStart("is_shareable")
|
|
b.PutBool(c.IsShareable)
|
|
b.Comma()
|
|
b.FieldStart("has_my_invite_links")
|
|
b.PutBool(c.HasMyInviteLinks)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (c *ChatFolderInfo) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatFolderInfo#309c140d to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("chatFolderInfo"); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: %w", err)
|
|
}
|
|
case "id":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field id: %w", err)
|
|
}
|
|
c.ID = value
|
|
case "name":
|
|
if err := c.Name.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field name: %w", err)
|
|
}
|
|
case "icon":
|
|
if err := c.Icon.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field icon: %w", err)
|
|
}
|
|
case "color_id":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field color_id: %w", err)
|
|
}
|
|
c.ColorID = value
|
|
case "is_shareable":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field is_shareable: %w", err)
|
|
}
|
|
c.IsShareable = value
|
|
case "has_my_invite_links":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatFolderInfo#309c140d: field has_my_invite_links: %w", err)
|
|
}
|
|
c.HasMyInviteLinks = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetID returns value of ID field.
|
|
func (c *ChatFolderInfo) GetID() (value int32) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.ID
|
|
}
|
|
|
|
// GetName returns value of Name field.
|
|
func (c *ChatFolderInfo) GetName() (value ChatFolderName) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Name
|
|
}
|
|
|
|
// GetIcon returns value of Icon field.
|
|
func (c *ChatFolderInfo) GetIcon() (value ChatFolderIcon) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Icon
|
|
}
|
|
|
|
// GetColorID returns value of ColorID field.
|
|
func (c *ChatFolderInfo) GetColorID() (value int32) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.ColorID
|
|
}
|
|
|
|
// GetIsShareable returns value of IsShareable field.
|
|
func (c *ChatFolderInfo) GetIsShareable() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.IsShareable
|
|
}
|
|
|
|
// GetHasMyInviteLinks returns value of HasMyInviteLinks field.
|
|
func (c *ChatFolderInfo) GetHasMyInviteLinks() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.HasMyInviteLinks
|
|
}
|