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 FactCheck struct {
Flags bin .Fields
NeedCheck bool
Country string
Text TextWithEntities
Hash int64
}
const FactCheckTypeID = 0xb89bfccf
var (
_ bin .Encoder = &FactCheck {}
_ bin .Decoder = &FactCheck {}
_ bin .BareEncoder = &FactCheck {}
_ bin .BareDecoder = &FactCheck {}
)
func (f *FactCheck ) Zero () bool {
if f == nil {
return true
}
if !(f .Flags .Zero ()) {
return false
}
if !(f .NeedCheck == false ) {
return false
}
if !(f .Country == "" ) {
return false
}
if !(f .Text .Zero ()) {
return false
}
if !(f .Hash == 0 ) {
return false
}
return true
}
func (f *FactCheck ) String () string {
if f == nil {
return "FactCheck(nil)"
}
type Alias FactCheck
return fmt .Sprintf ("FactCheck%+v" , Alias (*f ))
}
func (f *FactCheck ) FillFrom (from interface {
GetNeedCheck () (value bool )
GetCountry () (value string , ok bool )
GetText () (value TextWithEntities , ok bool )
GetHash () (value int64 )
}) {
f .NeedCheck = from .GetNeedCheck ()
if val , ok := from .GetCountry (); ok {
f .Country = val
}
if val , ok := from .GetText (); ok {
f .Text = val
}
f .Hash = from .GetHash ()
}
func (*FactCheck ) TypeID () uint32 {
return FactCheckTypeID
}
func (*FactCheck ) TypeName () string {
return "factCheck"
}
func (f *FactCheck ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "factCheck" ,
ID : FactCheckTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NeedCheck" ,
SchemaName : "need_check" ,
Null : !f .Flags .Has (0 ),
},
{
Name : "Country" ,
SchemaName : "country" ,
Null : !f .Flags .Has (1 ),
},
{
Name : "Text" ,
SchemaName : "text" ,
Null : !f .Flags .Has (1 ),
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (f *FactCheck ) SetFlags () {
if !(f .NeedCheck == false ) {
f .Flags .Set (0 )
}
if !(f .Country == "" ) {
f .Flags .Set (1 )
}
if !(f .Text .Zero ()) {
f .Flags .Set (1 )
}
}
func (f *FactCheck ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode factCheck#b89bfccf as nil" )
}
b .PutID (FactCheckTypeID )
return f .EncodeBare (b )
}
func (f *FactCheck ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode factCheck#b89bfccf as nil" )
}
f .SetFlags ()
if err := f .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode factCheck#b89bfccf: field flags: %w" , err )
}
if f .Flags .Has (1 ) {
b .PutString (f .Country )
}
if f .Flags .Has (1 ) {
if err := f .Text .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode factCheck#b89bfccf: field text: %w" , err )
}
}
b .PutLong (f .Hash )
return nil
}
func (f *FactCheck ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode factCheck#b89bfccf to nil" )
}
if err := b .ConsumeID (FactCheckTypeID ); err != nil {
return fmt .Errorf ("unable to decode factCheck#b89bfccf: %w" , err )
}
return f .DecodeBare (b )
}
func (f *FactCheck ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode factCheck#b89bfccf to nil" )
}
{
if err := f .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode factCheck#b89bfccf: field flags: %w" , err )
}
}
f .NeedCheck = f .Flags .Has (0 )
if f .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode factCheck#b89bfccf: field country: %w" , err )
}
f .Country = value
}
if f .Flags .Has (1 ) {
if err := f .Text .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode factCheck#b89bfccf: field text: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode factCheck#b89bfccf: field hash: %w" , err )
}
f .Hash = value
}
return nil
}
func (f *FactCheck ) SetNeedCheck (value bool ) {
if value {
f .Flags .Set (0 )
f .NeedCheck = true
} else {
f .Flags .Unset (0 )
f .NeedCheck = false
}
}
func (f *FactCheck ) GetNeedCheck () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (0 )
}
func (f *FactCheck ) SetCountry (value string ) {
f .Flags .Set (1 )
f .Country = value
}
func (f *FactCheck ) GetCountry () (value string , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (1 ) {
return value , false
}
return f .Country , true
}
func (f *FactCheck ) SetText (value TextWithEntities ) {
f .Flags .Set (1 )
f .Text = value
}
func (f *FactCheck ) GetText () (value TextWithEntities , ok bool ) {
if f == nil {
return
}
if !f .Flags .Has (1 ) {
return value , false
}
return f .Text , true
}
func (f *FactCheck ) GetHash () (value int64 ) {
if f == nil {
return
}
return f .Hash
}
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 .