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 StoriesStealthMode struct {
Flags bin .Fields
ActiveUntilDate int
CooldownUntilDate int
}
const StoriesStealthModeTypeID = 0x712e27fd
var (
_ bin .Encoder = &StoriesStealthMode {}
_ bin .Decoder = &StoriesStealthMode {}
_ bin .BareEncoder = &StoriesStealthMode {}
_ bin .BareDecoder = &StoriesStealthMode {}
)
func (s *StoriesStealthMode ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .ActiveUntilDate == 0 ) {
return false
}
if !(s .CooldownUntilDate == 0 ) {
return false
}
return true
}
func (s *StoriesStealthMode ) String () string {
if s == nil {
return "StoriesStealthMode(nil)"
}
type Alias StoriesStealthMode
return fmt .Sprintf ("StoriesStealthMode%+v" , Alias (*s ))
}
func (s *StoriesStealthMode ) FillFrom (from interface {
GetActiveUntilDate () (value int , ok bool )
GetCooldownUntilDate () (value int , ok bool )
}) {
if val , ok := from .GetActiveUntilDate (); ok {
s .ActiveUntilDate = val
}
if val , ok := from .GetCooldownUntilDate (); ok {
s .CooldownUntilDate = val
}
}
func (*StoriesStealthMode ) TypeID () uint32 {
return StoriesStealthModeTypeID
}
func (*StoriesStealthMode ) TypeName () string {
return "storiesStealthMode"
}
func (s *StoriesStealthMode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "storiesStealthMode" ,
ID : StoriesStealthModeTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ActiveUntilDate" ,
SchemaName : "active_until_date" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "CooldownUntilDate" ,
SchemaName : "cooldown_until_date" ,
Null : !s .Flags .Has (1 ),
},
}
return typ
}
func (s *StoriesStealthMode ) SetFlags () {
if !(s .ActiveUntilDate == 0 ) {
s .Flags .Set (0 )
}
if !(s .CooldownUntilDate == 0 ) {
s .Flags .Set (1 )
}
}
func (s *StoriesStealthMode ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storiesStealthMode#712e27fd as nil" )
}
b .PutID (StoriesStealthModeTypeID )
return s .EncodeBare (b )
}
func (s *StoriesStealthMode ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storiesStealthMode#712e27fd as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storiesStealthMode#712e27fd: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutInt (s .ActiveUntilDate )
}
if s .Flags .Has (1 ) {
b .PutInt (s .CooldownUntilDate )
}
return nil
}
func (s *StoriesStealthMode ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storiesStealthMode#712e27fd to nil" )
}
if err := b .ConsumeID (StoriesStealthModeTypeID ); err != nil {
return fmt .Errorf ("unable to decode storiesStealthMode#712e27fd: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesStealthMode ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storiesStealthMode#712e27fd to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode storiesStealthMode#712e27fd: field flags: %w" , err )
}
}
if s .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode storiesStealthMode#712e27fd: field active_until_date: %w" , err )
}
s .ActiveUntilDate = value
}
if s .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode storiesStealthMode#712e27fd: field cooldown_until_date: %w" , err )
}
s .CooldownUntilDate = value
}
return nil
}
func (s *StoriesStealthMode ) SetActiveUntilDate (value int ) {
s .Flags .Set (0 )
s .ActiveUntilDate = value
}
func (s *StoriesStealthMode ) GetActiveUntilDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .ActiveUntilDate , true
}
func (s *StoriesStealthMode ) SetCooldownUntilDate (value int ) {
s .Flags .Set (1 )
s .CooldownUntilDate = value
}
func (s *StoriesStealthMode ) GetCooldownUntilDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .CooldownUntilDate , true
}
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 .