move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,902 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// StoryPrivacySettingsEveryone represents TL type `storyPrivacySettingsEveryone#22d1053a`.
|
||||
type StoryPrivacySettingsEveryone struct {
|
||||
// Identifiers of the users that can't see the story; always unknown and empty for
|
||||
// non-owned stories
|
||||
ExceptUserIDs []int64
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsEveryoneTypeID is TL type id of StoryPrivacySettingsEveryone.
|
||||
const StoryPrivacySettingsEveryoneTypeID = 0x22d1053a
|
||||
|
||||
// construct implements constructor of StoryPrivacySettingsClass.
|
||||
func (s StoryPrivacySettingsEveryone) construct() StoryPrivacySettingsClass { return &s }
|
||||
|
||||
// Ensuring interfaces in compile-time for StoryPrivacySettingsEveryone.
|
||||
var (
|
||||
_ bin.Encoder = &StoryPrivacySettingsEveryone{}
|
||||
_ bin.Decoder = &StoryPrivacySettingsEveryone{}
|
||||
_ bin.BareEncoder = &StoryPrivacySettingsEveryone{}
|
||||
_ bin.BareDecoder = &StoryPrivacySettingsEveryone{}
|
||||
|
||||
_ StoryPrivacySettingsClass = &StoryPrivacySettingsEveryone{}
|
||||
)
|
||||
|
||||
func (s *StoryPrivacySettingsEveryone) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.ExceptUserIDs == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *StoryPrivacySettingsEveryone) String() string {
|
||||
if s == nil {
|
||||
return "StoryPrivacySettingsEveryone(nil)"
|
||||
}
|
||||
type Alias StoryPrivacySettingsEveryone
|
||||
return fmt.Sprintf("StoryPrivacySettingsEveryone%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*StoryPrivacySettingsEveryone) TypeID() uint32 {
|
||||
return StoryPrivacySettingsEveryoneTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*StoryPrivacySettingsEveryone) TypeName() string {
|
||||
return "storyPrivacySettingsEveryone"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *StoryPrivacySettingsEveryone) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "storyPrivacySettingsEveryone",
|
||||
ID: StoryPrivacySettingsEveryoneTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ExceptUserIDs",
|
||||
SchemaName: "except_user_ids",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *StoryPrivacySettingsEveryone) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsEveryone#22d1053a as nil")
|
||||
}
|
||||
b.PutID(StoryPrivacySettingsEveryoneTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *StoryPrivacySettingsEveryone) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsEveryone#22d1053a as nil")
|
||||
}
|
||||
b.PutInt(len(s.ExceptUserIDs))
|
||||
for _, v := range s.ExceptUserIDs {
|
||||
b.PutInt53(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *StoryPrivacySettingsEveryone) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsEveryone#22d1053a to nil")
|
||||
}
|
||||
if err := b.ConsumeID(StoryPrivacySettingsEveryoneTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *StoryPrivacySettingsEveryone) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsEveryone#22d1053a to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: field except_user_ids: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
s.ExceptUserIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: field except_user_ids: %w", err)
|
||||
}
|
||||
s.ExceptUserIDs = append(s.ExceptUserIDs, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (s *StoryPrivacySettingsEveryone) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsEveryone#22d1053a as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("storyPrivacySettingsEveryone")
|
||||
b.Comma()
|
||||
b.FieldStart("except_user_ids")
|
||||
b.ArrStart()
|
||||
for _, v := range s.ExceptUserIDs {
|
||||
b.PutInt53(v)
|
||||
b.Comma()
|
||||
}
|
||||
b.StripComma()
|
||||
b.ArrEnd()
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (s *StoryPrivacySettingsEveryone) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsEveryone#22d1053a to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("storyPrivacySettingsEveryone"); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: %w", err)
|
||||
}
|
||||
case "except_user_ids":
|
||||
if err := b.Arr(func(b tdjson.Decoder) error {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: field except_user_ids: %w", err)
|
||||
}
|
||||
s.ExceptUserIDs = append(s.ExceptUserIDs, value)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsEveryone#22d1053a: field except_user_ids: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetExceptUserIDs returns value of ExceptUserIDs field.
|
||||
func (s *StoryPrivacySettingsEveryone) GetExceptUserIDs() (value []int64) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.ExceptUserIDs
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsContacts represents TL type `storyPrivacySettingsContacts#35515d71`.
|
||||
type StoryPrivacySettingsContacts struct {
|
||||
// User identifiers of the contacts that can't see the story; always unknown and empty
|
||||
// for non-owned stories
|
||||
ExceptUserIDs []int64
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsContactsTypeID is TL type id of StoryPrivacySettingsContacts.
|
||||
const StoryPrivacySettingsContactsTypeID = 0x35515d71
|
||||
|
||||
// construct implements constructor of StoryPrivacySettingsClass.
|
||||
func (s StoryPrivacySettingsContacts) construct() StoryPrivacySettingsClass { return &s }
|
||||
|
||||
// Ensuring interfaces in compile-time for StoryPrivacySettingsContacts.
|
||||
var (
|
||||
_ bin.Encoder = &StoryPrivacySettingsContacts{}
|
||||
_ bin.Decoder = &StoryPrivacySettingsContacts{}
|
||||
_ bin.BareEncoder = &StoryPrivacySettingsContacts{}
|
||||
_ bin.BareDecoder = &StoryPrivacySettingsContacts{}
|
||||
|
||||
_ StoryPrivacySettingsClass = &StoryPrivacySettingsContacts{}
|
||||
)
|
||||
|
||||
func (s *StoryPrivacySettingsContacts) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.ExceptUserIDs == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *StoryPrivacySettingsContacts) String() string {
|
||||
if s == nil {
|
||||
return "StoryPrivacySettingsContacts(nil)"
|
||||
}
|
||||
type Alias StoryPrivacySettingsContacts
|
||||
return fmt.Sprintf("StoryPrivacySettingsContacts%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*StoryPrivacySettingsContacts) TypeID() uint32 {
|
||||
return StoryPrivacySettingsContactsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*StoryPrivacySettingsContacts) TypeName() string {
|
||||
return "storyPrivacySettingsContacts"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *StoryPrivacySettingsContacts) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "storyPrivacySettingsContacts",
|
||||
ID: StoryPrivacySettingsContactsTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ExceptUserIDs",
|
||||
SchemaName: "except_user_ids",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *StoryPrivacySettingsContacts) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsContacts#35515d71 as nil")
|
||||
}
|
||||
b.PutID(StoryPrivacySettingsContactsTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *StoryPrivacySettingsContacts) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsContacts#35515d71 as nil")
|
||||
}
|
||||
b.PutInt(len(s.ExceptUserIDs))
|
||||
for _, v := range s.ExceptUserIDs {
|
||||
b.PutInt53(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *StoryPrivacySettingsContacts) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsContacts#35515d71 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(StoryPrivacySettingsContactsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *StoryPrivacySettingsContacts) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsContacts#35515d71 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: field except_user_ids: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
s.ExceptUserIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: field except_user_ids: %w", err)
|
||||
}
|
||||
s.ExceptUserIDs = append(s.ExceptUserIDs, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (s *StoryPrivacySettingsContacts) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsContacts#35515d71 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("storyPrivacySettingsContacts")
|
||||
b.Comma()
|
||||
b.FieldStart("except_user_ids")
|
||||
b.ArrStart()
|
||||
for _, v := range s.ExceptUserIDs {
|
||||
b.PutInt53(v)
|
||||
b.Comma()
|
||||
}
|
||||
b.StripComma()
|
||||
b.ArrEnd()
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (s *StoryPrivacySettingsContacts) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsContacts#35515d71 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("storyPrivacySettingsContacts"); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: %w", err)
|
||||
}
|
||||
case "except_user_ids":
|
||||
if err := b.Arr(func(b tdjson.Decoder) error {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: field except_user_ids: %w", err)
|
||||
}
|
||||
s.ExceptUserIDs = append(s.ExceptUserIDs, value)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsContacts#35515d71: field except_user_ids: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetExceptUserIDs returns value of ExceptUserIDs field.
|
||||
func (s *StoryPrivacySettingsContacts) GetExceptUserIDs() (value []int64) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.ExceptUserIDs
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsCloseFriends represents TL type `storyPrivacySettingsCloseFriends#7cff8b60`.
|
||||
type StoryPrivacySettingsCloseFriends struct {
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsCloseFriendsTypeID is TL type id of StoryPrivacySettingsCloseFriends.
|
||||
const StoryPrivacySettingsCloseFriendsTypeID = 0x7cff8b60
|
||||
|
||||
// construct implements constructor of StoryPrivacySettingsClass.
|
||||
func (s StoryPrivacySettingsCloseFriends) construct() StoryPrivacySettingsClass { return &s }
|
||||
|
||||
// Ensuring interfaces in compile-time for StoryPrivacySettingsCloseFriends.
|
||||
var (
|
||||
_ bin.Encoder = &StoryPrivacySettingsCloseFriends{}
|
||||
_ bin.Decoder = &StoryPrivacySettingsCloseFriends{}
|
||||
_ bin.BareEncoder = &StoryPrivacySettingsCloseFriends{}
|
||||
_ bin.BareDecoder = &StoryPrivacySettingsCloseFriends{}
|
||||
|
||||
_ StoryPrivacySettingsClass = &StoryPrivacySettingsCloseFriends{}
|
||||
)
|
||||
|
||||
func (s *StoryPrivacySettingsCloseFriends) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *StoryPrivacySettingsCloseFriends) String() string {
|
||||
if s == nil {
|
||||
return "StoryPrivacySettingsCloseFriends(nil)"
|
||||
}
|
||||
type Alias StoryPrivacySettingsCloseFriends
|
||||
return fmt.Sprintf("StoryPrivacySettingsCloseFriends%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*StoryPrivacySettingsCloseFriends) TypeID() uint32 {
|
||||
return StoryPrivacySettingsCloseFriendsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*StoryPrivacySettingsCloseFriends) TypeName() string {
|
||||
return "storyPrivacySettingsCloseFriends"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *StoryPrivacySettingsCloseFriends) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "storyPrivacySettingsCloseFriends",
|
||||
ID: StoryPrivacySettingsCloseFriendsTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsCloseFriends#7cff8b60 as nil")
|
||||
}
|
||||
b.PutID(StoryPrivacySettingsCloseFriendsTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsCloseFriends#7cff8b60 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsCloseFriends#7cff8b60 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(StoryPrivacySettingsCloseFriendsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsCloseFriends#7cff8b60: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsCloseFriends#7cff8b60 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsCloseFriends#7cff8b60 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("storyPrivacySettingsCloseFriends")
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (s *StoryPrivacySettingsCloseFriends) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsCloseFriends#7cff8b60 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("storyPrivacySettingsCloseFriends"); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsCloseFriends#7cff8b60: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsSelectedUsers represents TL type `storyPrivacySettingsSelectedUsers#84d7d27b`.
|
||||
type StoryPrivacySettingsSelectedUsers struct {
|
||||
// Identifiers of the users; always unknown and empty for non-owned stories
|
||||
UserIDs []int64
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsSelectedUsersTypeID is TL type id of StoryPrivacySettingsSelectedUsers.
|
||||
const StoryPrivacySettingsSelectedUsersTypeID = 0x84d7d27b
|
||||
|
||||
// construct implements constructor of StoryPrivacySettingsClass.
|
||||
func (s StoryPrivacySettingsSelectedUsers) construct() StoryPrivacySettingsClass { return &s }
|
||||
|
||||
// Ensuring interfaces in compile-time for StoryPrivacySettingsSelectedUsers.
|
||||
var (
|
||||
_ bin.Encoder = &StoryPrivacySettingsSelectedUsers{}
|
||||
_ bin.Decoder = &StoryPrivacySettingsSelectedUsers{}
|
||||
_ bin.BareEncoder = &StoryPrivacySettingsSelectedUsers{}
|
||||
_ bin.BareDecoder = &StoryPrivacySettingsSelectedUsers{}
|
||||
|
||||
_ StoryPrivacySettingsClass = &StoryPrivacySettingsSelectedUsers{}
|
||||
)
|
||||
|
||||
func (s *StoryPrivacySettingsSelectedUsers) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.UserIDs == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) String() string {
|
||||
if s == nil {
|
||||
return "StoryPrivacySettingsSelectedUsers(nil)"
|
||||
}
|
||||
type Alias StoryPrivacySettingsSelectedUsers
|
||||
return fmt.Sprintf("StoryPrivacySettingsSelectedUsers%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*StoryPrivacySettingsSelectedUsers) TypeID() uint32 {
|
||||
return StoryPrivacySettingsSelectedUsersTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*StoryPrivacySettingsSelectedUsers) TypeName() string {
|
||||
return "storyPrivacySettingsSelectedUsers"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "storyPrivacySettingsSelectedUsers",
|
||||
ID: StoryPrivacySettingsSelectedUsersTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "UserIDs",
|
||||
SchemaName: "user_ids",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsSelectedUsers#84d7d27b as nil")
|
||||
}
|
||||
b.PutID(StoryPrivacySettingsSelectedUsersTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsSelectedUsers#84d7d27b as nil")
|
||||
}
|
||||
b.PutInt(len(s.UserIDs))
|
||||
for _, v := range s.UserIDs {
|
||||
b.PutInt53(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsSelectedUsers#84d7d27b to nil")
|
||||
}
|
||||
if err := b.ConsumeID(StoryPrivacySettingsSelectedUsersTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsSelectedUsers#84d7d27b to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: field user_ids: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
s.UserIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: field user_ids: %w", err)
|
||||
}
|
||||
s.UserIDs = append(s.UserIDs, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode storyPrivacySettingsSelectedUsers#84d7d27b as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("storyPrivacySettingsSelectedUsers")
|
||||
b.Comma()
|
||||
b.FieldStart("user_ids")
|
||||
b.ArrStart()
|
||||
for _, v := range s.UserIDs {
|
||||
b.PutInt53(v)
|
||||
b.Comma()
|
||||
}
|
||||
b.StripComma()
|
||||
b.ArrEnd()
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode storyPrivacySettingsSelectedUsers#84d7d27b to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("storyPrivacySettingsSelectedUsers"); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: %w", err)
|
||||
}
|
||||
case "user_ids":
|
||||
if err := b.Arr(func(b tdjson.Decoder) error {
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: field user_ids: %w", err)
|
||||
}
|
||||
s.UserIDs = append(s.UserIDs, value)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("unable to decode storyPrivacySettingsSelectedUsers#84d7d27b: field user_ids: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetUserIDs returns value of UserIDs field.
|
||||
func (s *StoryPrivacySettingsSelectedUsers) GetUserIDs() (value []int64) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.UserIDs
|
||||
}
|
||||
|
||||
// StoryPrivacySettingsClassName is schema name of StoryPrivacySettingsClass.
|
||||
const StoryPrivacySettingsClassName = "StoryPrivacySettings"
|
||||
|
||||
// StoryPrivacySettingsClass represents StoryPrivacySettings generic type.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := tdapi.DecodeStoryPrivacySettings(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *tdapi.StoryPrivacySettingsEveryone: // storyPrivacySettingsEveryone#22d1053a
|
||||
// case *tdapi.StoryPrivacySettingsContacts: // storyPrivacySettingsContacts#35515d71
|
||||
// case *tdapi.StoryPrivacySettingsCloseFriends: // storyPrivacySettingsCloseFriends#7cff8b60
|
||||
// case *tdapi.StoryPrivacySettingsSelectedUsers: // storyPrivacySettingsSelectedUsers#84d7d27b
|
||||
// default: panic(v)
|
||||
// }
|
||||
type StoryPrivacySettingsClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() StoryPrivacySettingsClass
|
||||
|
||||
// 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
|
||||
|
||||
EncodeTDLibJSON(b tdjson.Encoder) error
|
||||
DecodeTDLibJSON(b tdjson.Decoder) error
|
||||
}
|
||||
|
||||
// DecodeStoryPrivacySettings implements binary de-serialization for StoryPrivacySettingsClass.
|
||||
func DecodeStoryPrivacySettings(buf *bin.Buffer) (StoryPrivacySettingsClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case StoryPrivacySettingsEveryoneTypeID:
|
||||
// Decoding storyPrivacySettingsEveryone#22d1053a.
|
||||
v := StoryPrivacySettingsEveryone{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case StoryPrivacySettingsContactsTypeID:
|
||||
// Decoding storyPrivacySettingsContacts#35515d71.
|
||||
v := StoryPrivacySettingsContacts{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case StoryPrivacySettingsCloseFriendsTypeID:
|
||||
// Decoding storyPrivacySettingsCloseFriends#7cff8b60.
|
||||
v := StoryPrivacySettingsCloseFriends{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case StoryPrivacySettingsSelectedUsersTypeID:
|
||||
// Decoding storyPrivacySettingsSelectedUsers#84d7d27b.
|
||||
v := StoryPrivacySettingsSelectedUsers{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// DecodeTDLibJSONStoryPrivacySettings implements binary de-serialization for StoryPrivacySettingsClass.
|
||||
func DecodeTDLibJSONStoryPrivacySettings(buf tdjson.Decoder) (StoryPrivacySettingsClass, error) {
|
||||
id, err := buf.FindTypeID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case "storyPrivacySettingsEveryone":
|
||||
// Decoding storyPrivacySettingsEveryone#22d1053a.
|
||||
v := StoryPrivacySettingsEveryone{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case "storyPrivacySettingsContacts":
|
||||
// Decoding storyPrivacySettingsContacts#35515d71.
|
||||
v := StoryPrivacySettingsContacts{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case "storyPrivacySettingsCloseFriends":
|
||||
// Decoding storyPrivacySettingsCloseFriends#7cff8b60.
|
||||
v := StoryPrivacySettingsCloseFriends{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case "storyPrivacySettingsSelectedUsers":
|
||||
// Decoding storyPrivacySettingsSelectedUsers#84d7d27b.
|
||||
v := StoryPrivacySettingsSelectedUsers{}
|
||||
if err := v.DecodeTDLibJSON(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode StoryPrivacySettingsClass: %w", tdjson.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// StoryPrivacySettings boxes the StoryPrivacySettingsClass providing a helper.
|
||||
type StoryPrivacySettingsBox struct {
|
||||
StoryPrivacySettings StoryPrivacySettingsClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for StoryPrivacySettingsBox.
|
||||
func (b *StoryPrivacySettingsBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode StoryPrivacySettingsBox to nil")
|
||||
}
|
||||
v, err := DecodeStoryPrivacySettings(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.StoryPrivacySettings = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for StoryPrivacySettingsBox.
|
||||
func (b *StoryPrivacySettingsBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.StoryPrivacySettings == nil {
|
||||
return fmt.Errorf("unable to encode StoryPrivacySettingsClass as nil")
|
||||
}
|
||||
return b.StoryPrivacySettings.Encode(buf)
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements bin.Decoder for StoryPrivacySettingsBox.
|
||||
func (b *StoryPrivacySettingsBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode StoryPrivacySettingsBox to nil")
|
||||
}
|
||||
v, err := DecodeTDLibJSONStoryPrivacySettings(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.StoryPrivacySettings = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements bin.Encode for StoryPrivacySettingsBox.
|
||||
func (b *StoryPrivacySettingsBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
|
||||
if b == nil || b.StoryPrivacySettings == nil {
|
||||
return fmt.Errorf("unable to encode StoryPrivacySettingsClass as nil")
|
||||
}
|
||||
return b.StoryPrivacySettings.EncodeTDLibJSON(buf)
|
||||
}
|
||||
Reference in New Issue
Block a user