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 RecentStory struct {
Flags bin .Fields
Live bool
MaxID int
}
const RecentStoryTypeID = 0x711d692d
var (
_ bin .Encoder = &RecentStory {}
_ bin .Decoder = &RecentStory {}
_ bin .BareEncoder = &RecentStory {}
_ bin .BareDecoder = &RecentStory {}
)
func (r *RecentStory ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .Live == false ) {
return false
}
if !(r .MaxID == 0 ) {
return false
}
return true
}
func (r *RecentStory ) String () string {
if r == nil {
return "RecentStory(nil)"
}
type Alias RecentStory
return fmt .Sprintf ("RecentStory%+v" , Alias (*r ))
}
func (r *RecentStory ) FillFrom (from interface {
GetLive () (value bool )
GetMaxID () (value int , ok bool )
}) {
r .Live = from .GetLive ()
if val , ok := from .GetMaxID (); ok {
r .MaxID = val
}
}
func (*RecentStory ) TypeID () uint32 {
return RecentStoryTypeID
}
func (*RecentStory ) TypeName () string {
return "recentStory"
}
func (r *RecentStory ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "recentStory" ,
ID : RecentStoryTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Live" ,
SchemaName : "live" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "MaxID" ,
SchemaName : "max_id" ,
Null : !r .Flags .Has (1 ),
},
}
return typ
}
func (r *RecentStory ) SetFlags () {
if !(r .Live == false ) {
r .Flags .Set (0 )
}
if !(r .MaxID == 0 ) {
r .Flags .Set (1 )
}
}
func (r *RecentStory ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode recentStory#711d692d as nil" )
}
b .PutID (RecentStoryTypeID )
return r .EncodeBare (b )
}
func (r *RecentStory ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode recentStory#711d692d as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode recentStory#711d692d: field flags: %w" , err )
}
if r .Flags .Has (1 ) {
b .PutInt (r .MaxID )
}
return nil
}
func (r *RecentStory ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode recentStory#711d692d to nil" )
}
if err := b .ConsumeID (RecentStoryTypeID ); err != nil {
return fmt .Errorf ("unable to decode recentStory#711d692d: %w" , err )
}
return r .DecodeBare (b )
}
func (r *RecentStory ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode recentStory#711d692d to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode recentStory#711d692d: field flags: %w" , err )
}
}
r .Live = r .Flags .Has (0 )
if r .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode recentStory#711d692d: field max_id: %w" , err )
}
r .MaxID = value
}
return nil
}
func (r *RecentStory ) SetLive (value bool ) {
if value {
r .Flags .Set (0 )
r .Live = true
} else {
r .Flags .Unset (0 )
r .Live = false
}
}
func (r *RecentStory ) GetLive () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (0 )
}
func (r *RecentStory ) SetMaxID (value int ) {
r .Flags .Set (1 )
r .MaxID = value
}
func (r *RecentStory ) GetMaxID () (value int , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .MaxID , true
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .