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 SearchPostsFlood struct {
Flags bin .Fields
QueryIsFree bool
TotalDaily int
Remains int
WaitTill int
StarsAmount int64
}
const SearchPostsFloodTypeID = 0x3e0b5b6a
var (
_ bin .Encoder = &SearchPostsFlood {}
_ bin .Decoder = &SearchPostsFlood {}
_ bin .BareEncoder = &SearchPostsFlood {}
_ bin .BareDecoder = &SearchPostsFlood {}
)
func (s *SearchPostsFlood ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .QueryIsFree == false ) {
return false
}
if !(s .TotalDaily == 0 ) {
return false
}
if !(s .Remains == 0 ) {
return false
}
if !(s .WaitTill == 0 ) {
return false
}
if !(s .StarsAmount == 0 ) {
return false
}
return true
}
func (s *SearchPostsFlood ) String () string {
if s == nil {
return "SearchPostsFlood(nil)"
}
type Alias SearchPostsFlood
return fmt .Sprintf ("SearchPostsFlood%+v" , Alias (*s ))
}
func (s *SearchPostsFlood ) FillFrom (from interface {
GetQueryIsFree () (value bool )
GetTotalDaily () (value int )
GetRemains () (value int )
GetWaitTill () (value int , ok bool )
GetStarsAmount () (value int64 )
}) {
s .QueryIsFree = from .GetQueryIsFree ()
s .TotalDaily = from .GetTotalDaily ()
s .Remains = from .GetRemains ()
if val , ok := from .GetWaitTill (); ok {
s .WaitTill = val
}
s .StarsAmount = from .GetStarsAmount ()
}
func (*SearchPostsFlood ) TypeID () uint32 {
return SearchPostsFloodTypeID
}
func (*SearchPostsFlood ) TypeName () string {
return "searchPostsFlood"
}
func (s *SearchPostsFlood ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "searchPostsFlood" ,
ID : SearchPostsFloodTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "QueryIsFree" ,
SchemaName : "query_is_free" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "TotalDaily" ,
SchemaName : "total_daily" ,
},
{
Name : "Remains" ,
SchemaName : "remains" ,
},
{
Name : "WaitTill" ,
SchemaName : "wait_till" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "StarsAmount" ,
SchemaName : "stars_amount" ,
},
}
return typ
}
func (s *SearchPostsFlood ) SetFlags () {
if !(s .QueryIsFree == false ) {
s .Flags .Set (0 )
}
if !(s .WaitTill == 0 ) {
s .Flags .Set (1 )
}
}
func (s *SearchPostsFlood ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode searchPostsFlood#3e0b5b6a as nil" )
}
b .PutID (SearchPostsFloodTypeID )
return s .EncodeBare (b )
}
func (s *SearchPostsFlood ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode searchPostsFlood#3e0b5b6a as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode searchPostsFlood#3e0b5b6a: field flags: %w" , err )
}
b .PutInt (s .TotalDaily )
b .PutInt (s .Remains )
if s .Flags .Has (1 ) {
b .PutInt (s .WaitTill )
}
b .PutLong (s .StarsAmount )
return nil
}
func (s *SearchPostsFlood ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode searchPostsFlood#3e0b5b6a to nil" )
}
if err := b .ConsumeID (SearchPostsFloodTypeID ); err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SearchPostsFlood ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode searchPostsFlood#3e0b5b6a to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: field flags: %w" , err )
}
}
s .QueryIsFree = s .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: field total_daily: %w" , err )
}
s .TotalDaily = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: field remains: %w" , err )
}
s .Remains = value
}
if s .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: field wait_till: %w" , err )
}
s .WaitTill = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode searchPostsFlood#3e0b5b6a: field stars_amount: %w" , err )
}
s .StarsAmount = value
}
return nil
}
func (s *SearchPostsFlood ) SetQueryIsFree (value bool ) {
if value {
s .Flags .Set (0 )
s .QueryIsFree = true
} else {
s .Flags .Unset (0 )
s .QueryIsFree = false
}
}
func (s *SearchPostsFlood ) GetQueryIsFree () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *SearchPostsFlood ) GetTotalDaily () (value int ) {
if s == nil {
return
}
return s .TotalDaily
}
func (s *SearchPostsFlood ) GetRemains () (value int ) {
if s == nil {
return
}
return s .Remains
}
func (s *SearchPostsFlood ) SetWaitTill (value int ) {
s .Flags .Set (1 )
s .WaitTill = value
}
func (s *SearchPostsFlood ) GetWaitTill () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .WaitTill , true
}
func (s *SearchPostsFlood ) GetStarsAmount () (value int64 ) {
if s == nil {
return
}
return s .StarsAmount
}
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 .