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 ReportResultChooseOption struct {
Title string
Options []MessageReportOption
}
const ReportResultChooseOptionTypeID = 0xf0e4e0b6
func (r ReportResultChooseOption ) construct () ReportResultClass { return &r }
var (
_ bin .Encoder = &ReportResultChooseOption {}
_ bin .Decoder = &ReportResultChooseOption {}
_ bin .BareEncoder = &ReportResultChooseOption {}
_ bin .BareDecoder = &ReportResultChooseOption {}
_ ReportResultClass = &ReportResultChooseOption {}
)
func (r *ReportResultChooseOption ) Zero () bool {
if r == nil {
return true
}
if !(r .Title == "" ) {
return false
}
if !(r .Options == nil ) {
return false
}
return true
}
func (r *ReportResultChooseOption ) String () string {
if r == nil {
return "ReportResultChooseOption(nil)"
}
type Alias ReportResultChooseOption
return fmt .Sprintf ("ReportResultChooseOption%+v" , Alias (*r ))
}
func (r *ReportResultChooseOption ) FillFrom (from interface {
GetTitle () (value string )
GetOptions () (value []MessageReportOption )
}) {
r .Title = from .GetTitle ()
r .Options = from .GetOptions ()
}
func (*ReportResultChooseOption ) TypeID () uint32 {
return ReportResultChooseOptionTypeID
}
func (*ReportResultChooseOption ) TypeName () string {
return "reportResultChooseOption"
}
func (r *ReportResultChooseOption ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reportResultChooseOption" ,
ID : ReportResultChooseOptionTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Options" ,
SchemaName : "options" ,
},
}
return typ
}
func (r *ReportResultChooseOption ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultChooseOption#f0e4e0b6 as nil" )
}
b .PutID (ReportResultChooseOptionTypeID )
return r .EncodeBare (b )
}
func (r *ReportResultChooseOption ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultChooseOption#f0e4e0b6 as nil" )
}
b .PutString (r .Title )
b .PutVectorHeader (len (r .Options ))
for idx , v := range r .Options {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reportResultChooseOption#f0e4e0b6: field options element with index %d: %w" , idx , err )
}
}
return nil
}
func (r *ReportResultChooseOption ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultChooseOption#f0e4e0b6 to nil" )
}
if err := b .ConsumeID (ReportResultChooseOptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode reportResultChooseOption#f0e4e0b6: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReportResultChooseOption ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultChooseOption#f0e4e0b6 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode reportResultChooseOption#f0e4e0b6: field title: %w" , err )
}
r .Title = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w" , err )
}
if headerLen > 0 {
r .Options = make ([]MessageReportOption , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value MessageReportOption
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w" , err )
}
r .Options = append (r .Options , value )
}
}
return nil
}
func (r *ReportResultChooseOption ) GetTitle () (value string ) {
if r == nil {
return
}
return r .Title
}
func (r *ReportResultChooseOption ) GetOptions () (value []MessageReportOption ) {
if r == nil {
return
}
return r .Options
}
type ReportResultAddComment struct {
Flags bin .Fields
Optional bool
Option []byte
}
const ReportResultAddCommentTypeID = 0x6f09ac31
func (r ReportResultAddComment ) construct () ReportResultClass { return &r }
var (
_ bin .Encoder = &ReportResultAddComment {}
_ bin .Decoder = &ReportResultAddComment {}
_ bin .BareEncoder = &ReportResultAddComment {}
_ bin .BareDecoder = &ReportResultAddComment {}
_ ReportResultClass = &ReportResultAddComment {}
)
func (r *ReportResultAddComment ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .Optional == false ) {
return false
}
if !(r .Option == nil ) {
return false
}
return true
}
func (r *ReportResultAddComment ) String () string {
if r == nil {
return "ReportResultAddComment(nil)"
}
type Alias ReportResultAddComment
return fmt .Sprintf ("ReportResultAddComment%+v" , Alias (*r ))
}
func (r *ReportResultAddComment ) FillFrom (from interface {
GetOptional () (value bool )
GetOption () (value []byte )
}) {
r .Optional = from .GetOptional ()
r .Option = from .GetOption ()
}
func (*ReportResultAddComment ) TypeID () uint32 {
return ReportResultAddCommentTypeID
}
func (*ReportResultAddComment ) TypeName () string {
return "reportResultAddComment"
}
func (r *ReportResultAddComment ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reportResultAddComment" ,
ID : ReportResultAddCommentTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Optional" ,
SchemaName : "optional" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "Option" ,
SchemaName : "option" ,
},
}
return typ
}
func (r *ReportResultAddComment ) SetFlags () {
if !(r .Optional == false ) {
r .Flags .Set (0 )
}
}
func (r *ReportResultAddComment ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultAddComment#6f09ac31 as nil" )
}
b .PutID (ReportResultAddCommentTypeID )
return r .EncodeBare (b )
}
func (r *ReportResultAddComment ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultAddComment#6f09ac31 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reportResultAddComment#6f09ac31: field flags: %w" , err )
}
b .PutBytes (r .Option )
return nil
}
func (r *ReportResultAddComment ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultAddComment#6f09ac31 to nil" )
}
if err := b .ConsumeID (ReportResultAddCommentTypeID ); err != nil {
return fmt .Errorf ("unable to decode reportResultAddComment#6f09ac31: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReportResultAddComment ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultAddComment#6f09ac31 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode reportResultAddComment#6f09ac31: field flags: %w" , err )
}
}
r .Optional = r .Flags .Has (0 )
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode reportResultAddComment#6f09ac31: field option: %w" , err )
}
r .Option = value
}
return nil
}
func (r *ReportResultAddComment ) SetOptional (value bool ) {
if value {
r .Flags .Set (0 )
r .Optional = true
} else {
r .Flags .Unset (0 )
r .Optional = false
}
}
func (r *ReportResultAddComment ) GetOptional () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (0 )
}
func (r *ReportResultAddComment ) GetOption () (value []byte ) {
if r == nil {
return
}
return r .Option
}
type ReportResultReported struct {
}
const ReportResultReportedTypeID = 0x8db33c4b
func (r ReportResultReported ) construct () ReportResultClass { return &r }
var (
_ bin .Encoder = &ReportResultReported {}
_ bin .Decoder = &ReportResultReported {}
_ bin .BareEncoder = &ReportResultReported {}
_ bin .BareDecoder = &ReportResultReported {}
_ ReportResultClass = &ReportResultReported {}
)
func (r *ReportResultReported ) Zero () bool {
if r == nil {
return true
}
return true
}
func (r *ReportResultReported ) String () string {
if r == nil {
return "ReportResultReported(nil)"
}
type Alias ReportResultReported
return fmt .Sprintf ("ReportResultReported%+v" , Alias (*r ))
}
func (*ReportResultReported ) TypeID () uint32 {
return ReportResultReportedTypeID
}
func (*ReportResultReported ) TypeName () string {
return "reportResultReported"
}
func (r *ReportResultReported ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reportResultReported" ,
ID : ReportResultReportedTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (r *ReportResultReported ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultReported#8db33c4b as nil" )
}
b .PutID (ReportResultReportedTypeID )
return r .EncodeBare (b )
}
func (r *ReportResultReported ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reportResultReported#8db33c4b as nil" )
}
return nil
}
func (r *ReportResultReported ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultReported#8db33c4b to nil" )
}
if err := b .ConsumeID (ReportResultReportedTypeID ); err != nil {
return fmt .Errorf ("unable to decode reportResultReported#8db33c4b: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReportResultReported ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reportResultReported#8db33c4b to nil" )
}
return nil
}
const ReportResultClassName = "ReportResult"
type ReportResultClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ReportResultClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeReportResult (buf *bin .Buffer ) (ReportResultClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ReportResultChooseOptionTypeID :
v := ReportResultChooseOption {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReportResultClass: %w" , err )
}
return &v , nil
case ReportResultAddCommentTypeID :
v := ReportResultAddComment {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReportResultClass: %w" , err )
}
return &v , nil
case ReportResultReportedTypeID :
v := ReportResultReported {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReportResultClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ReportResultClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ReportResultBox struct {
ReportResult ReportResultClass
}
func (b *ReportResultBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ReportResultBox to nil" )
}
v , err := DecodeReportResult (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ReportResult = v
return nil
}
func (b *ReportResultBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ReportResult == nil {
return fmt .Errorf ("unable to encode ReportResultClass as nil" )
}
return b .ReportResult .Encode (buf )
}
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 .