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 StoriesAllStoriesNotModified struct {
Flags bin .Fields
State string
StealthMode StoriesStealthMode
}
const StoriesAllStoriesNotModifiedTypeID = 0x1158fe3e
func (a StoriesAllStoriesNotModified ) construct () StoriesAllStoriesClass { return &a }
var (
_ bin .Encoder = &StoriesAllStoriesNotModified {}
_ bin .Decoder = &StoriesAllStoriesNotModified {}
_ bin .BareEncoder = &StoriesAllStoriesNotModified {}
_ bin .BareDecoder = &StoriesAllStoriesNotModified {}
_ StoriesAllStoriesClass = &StoriesAllStoriesNotModified {}
)
func (a *StoriesAllStoriesNotModified ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .State == "" ) {
return false
}
if !(a .StealthMode .Zero ()) {
return false
}
return true
}
func (a *StoriesAllStoriesNotModified ) String () string {
if a == nil {
return "StoriesAllStoriesNotModified(nil)"
}
type Alias StoriesAllStoriesNotModified
return fmt .Sprintf ("StoriesAllStoriesNotModified%+v" , Alias (*a ))
}
func (a *StoriesAllStoriesNotModified ) FillFrom (from interface {
GetState () (value string )
GetStealthMode () (value StoriesStealthMode )
}) {
a .State = from .GetState ()
a .StealthMode = from .GetStealthMode ()
}
func (*StoriesAllStoriesNotModified ) TypeID () uint32 {
return StoriesAllStoriesNotModifiedTypeID
}
func (*StoriesAllStoriesNotModified ) TypeName () string {
return "stories.allStoriesNotModified"
}
func (a *StoriesAllStoriesNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.allStoriesNotModified" ,
ID : StoriesAllStoriesNotModifiedTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "State" ,
SchemaName : "state" ,
},
{
Name : "StealthMode" ,
SchemaName : "stealth_mode" ,
},
}
return typ
}
func (a *StoriesAllStoriesNotModified ) SetFlags () {
}
func (a *StoriesAllStoriesNotModified ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.allStoriesNotModified#1158fe3e as nil" )
}
b .PutID (StoriesAllStoriesNotModifiedTypeID )
return a .EncodeBare (b )
}
func (a *StoriesAllStoriesNotModified ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.allStoriesNotModified#1158fe3e as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStoriesNotModified#1158fe3e: field flags: %w" , err )
}
b .PutString (a .State )
if err := a .StealthMode .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStoriesNotModified#1158fe3e: field stealth_mode: %w" , err )
}
return nil
}
func (a *StoriesAllStoriesNotModified ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.allStoriesNotModified#1158fe3e to nil" )
}
if err := b .ConsumeID (StoriesAllStoriesNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.allStoriesNotModified#1158fe3e: %w" , err )
}
return a .DecodeBare (b )
}
func (a *StoriesAllStoriesNotModified ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.allStoriesNotModified#1158fe3e to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.allStoriesNotModified#1158fe3e: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStoriesNotModified#1158fe3e: field state: %w" , err )
}
a .State = value
}
{
if err := a .StealthMode .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.allStoriesNotModified#1158fe3e: field stealth_mode: %w" , err )
}
}
return nil
}
func (a *StoriesAllStoriesNotModified ) GetState () (value string ) {
if a == nil {
return
}
return a .State
}
func (a *StoriesAllStoriesNotModified ) GetStealthMode () (value StoriesStealthMode ) {
if a == nil {
return
}
return a .StealthMode
}
type StoriesAllStories struct {
Flags bin .Fields
HasMore bool
Count int
State string
PeerStories []PeerStories
Chats []ChatClass
Users []UserClass
StealthMode StoriesStealthMode
}
const StoriesAllStoriesTypeID = 0x6efc5e81
func (a StoriesAllStories ) construct () StoriesAllStoriesClass { return &a }
var (
_ bin .Encoder = &StoriesAllStories {}
_ bin .Decoder = &StoriesAllStories {}
_ bin .BareEncoder = &StoriesAllStories {}
_ bin .BareDecoder = &StoriesAllStories {}
_ StoriesAllStoriesClass = &StoriesAllStories {}
)
func (a *StoriesAllStories ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .HasMore == false ) {
return false
}
if !(a .Count == 0 ) {
return false
}
if !(a .State == "" ) {
return false
}
if !(a .PeerStories == nil ) {
return false
}
if !(a .Chats == nil ) {
return false
}
if !(a .Users == nil ) {
return false
}
if !(a .StealthMode .Zero ()) {
return false
}
return true
}
func (a *StoriesAllStories ) String () string {
if a == nil {
return "StoriesAllStories(nil)"
}
type Alias StoriesAllStories
return fmt .Sprintf ("StoriesAllStories%+v" , Alias (*a ))
}
func (a *StoriesAllStories ) FillFrom (from interface {
GetHasMore () (value bool )
GetCount () (value int )
GetState () (value string )
GetPeerStories () (value []PeerStories )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetStealthMode () (value StoriesStealthMode )
}) {
a .HasMore = from .GetHasMore ()
a .Count = from .GetCount ()
a .State = from .GetState ()
a .PeerStories = from .GetPeerStories ()
a .Chats = from .GetChats ()
a .Users = from .GetUsers ()
a .StealthMode = from .GetStealthMode ()
}
func (*StoriesAllStories ) TypeID () uint32 {
return StoriesAllStoriesTypeID
}
func (*StoriesAllStories ) TypeName () string {
return "stories.allStories"
}
func (a *StoriesAllStories ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.allStories" ,
ID : StoriesAllStoriesTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasMore" ,
SchemaName : "has_more" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "State" ,
SchemaName : "state" ,
},
{
Name : "PeerStories" ,
SchemaName : "peer_stories" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "StealthMode" ,
SchemaName : "stealth_mode" ,
},
}
return typ
}
func (a *StoriesAllStories ) SetFlags () {
if !(a .HasMore == false ) {
a .Flags .Set (0 )
}
}
func (a *StoriesAllStories ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.allStories#6efc5e81 as nil" )
}
b .PutID (StoriesAllStoriesTypeID )
return a .EncodeBare (b )
}
func (a *StoriesAllStories ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.allStories#6efc5e81 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field flags: %w" , err )
}
b .PutInt (a .Count )
b .PutString (a .State )
b .PutVectorHeader (len (a .PeerStories ))
for idx , v := range a .PeerStories {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field peer_stories element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Chats ))
for idx , v := range a .Chats {
if v == nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Users ))
for idx , v := range a .Users {
if v == nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field users element with index %d: %w" , idx , err )
}
}
if err := a .StealthMode .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.allStories#6efc5e81: field stealth_mode: %w" , err )
}
return nil
}
func (a *StoriesAllStories ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.allStories#6efc5e81 to nil" )
}
if err := b .ConsumeID (StoriesAllStoriesTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: %w" , err )
}
return a .DecodeBare (b )
}
func (a *StoriesAllStories ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.allStories#6efc5e81 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field flags: %w" , err )
}
}
a .HasMore = a .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field count: %w" , err )
}
a .Count = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field state: %w" , err )
}
a .State = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field peer_stories: %w" , err )
}
if headerLen > 0 {
a .PeerStories = make ([]PeerStories , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PeerStories
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field peer_stories: %w" , err )
}
a .PeerStories = append (a .PeerStories , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field chats: %w" , err )
}
if headerLen > 0 {
a .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field chats: %w" , err )
}
a .Chats = append (a .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field users: %w" , err )
}
if headerLen > 0 {
a .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field users: %w" , err )
}
a .Users = append (a .Users , value )
}
}
{
if err := a .StealthMode .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.allStories#6efc5e81: field stealth_mode: %w" , err )
}
}
return nil
}
func (a *StoriesAllStories ) SetHasMore (value bool ) {
if value {
a .Flags .Set (0 )
a .HasMore = true
} else {
a .Flags .Unset (0 )
a .HasMore = false
}
}
func (a *StoriesAllStories ) GetHasMore () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *StoriesAllStories ) GetCount () (value int ) {
if a == nil {
return
}
return a .Count
}
func (a *StoriesAllStories ) GetState () (value string ) {
if a == nil {
return
}
return a .State
}
func (a *StoriesAllStories ) GetPeerStories () (value []PeerStories ) {
if a == nil {
return
}
return a .PeerStories
}
func (a *StoriesAllStories ) GetChats () (value []ChatClass ) {
if a == nil {
return
}
return a .Chats
}
func (a *StoriesAllStories ) GetUsers () (value []UserClass ) {
if a == nil {
return
}
return a .Users
}
func (a *StoriesAllStories ) GetStealthMode () (value StoriesStealthMode ) {
if a == nil {
return
}
return a .StealthMode
}
func (a *StoriesAllStories ) MapChats () (value ChatClassArray ) {
return ChatClassArray (a .Chats )
}
func (a *StoriesAllStories ) MapUsers () (value UserClassArray ) {
return UserClassArray (a .Users )
}
const StoriesAllStoriesClassName = "stories.AllStories"
type StoriesAllStoriesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StoriesAllStoriesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetState () (value string )
GetStealthMode () (value StoriesStealthMode )
AsModified () (*StoriesAllStories , bool )
}
func (a *StoriesAllStoriesNotModified ) AsModified () (*StoriesAllStories , bool ) {
return nil , false
}
func (a *StoriesAllStories ) AsModified () (*StoriesAllStories , bool ) {
return a , true
}
func DecodeStoriesAllStories (buf *bin .Buffer ) (StoriesAllStoriesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StoriesAllStoriesNotModifiedTypeID :
v := StoriesAllStoriesNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoriesAllStoriesClass: %w" , err )
}
return &v , nil
case StoriesAllStoriesTypeID :
v := StoriesAllStories {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoriesAllStoriesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StoriesAllStoriesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StoriesAllStoriesBox struct {
AllStories StoriesAllStoriesClass
}
func (b *StoriesAllStoriesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StoriesAllStoriesBox to nil" )
}
v , err := DecodeStoriesAllStories (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .AllStories = v
return nil
}
func (b *StoriesAllStoriesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .AllStories == nil {
return fmt .Errorf ("unable to encode StoriesAllStoriesClass as nil" )
}
return b .AllStories .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 .