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 InputSingleMedia struct {
Flags bin .Fields
Media InputMediaClass
RandomID int64
Message string
Entities []MessageEntityClass
}
const InputSingleMediaTypeID = 0x1cc6e91f
var (
_ bin .Encoder = &InputSingleMedia {}
_ bin .Decoder = &InputSingleMedia {}
_ bin .BareEncoder = &InputSingleMedia {}
_ bin .BareDecoder = &InputSingleMedia {}
)
func (i *InputSingleMedia ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Media == nil ) {
return false
}
if !(i .RandomID == 0 ) {
return false
}
if !(i .Message == "" ) {
return false
}
if !(i .Entities == nil ) {
return false
}
return true
}
func (i *InputSingleMedia ) String () string {
if i == nil {
return "InputSingleMedia(nil)"
}
type Alias InputSingleMedia
return fmt .Sprintf ("InputSingleMedia%+v" , Alias (*i ))
}
func (i *InputSingleMedia ) FillFrom (from interface {
GetMedia () (value InputMediaClass )
GetRandomID () (value int64 )
GetMessage () (value string )
GetEntities () (value []MessageEntityClass , ok bool )
}) {
i .Media = from .GetMedia ()
i .RandomID = from .GetRandomID ()
i .Message = from .GetMessage ()
if val , ok := from .GetEntities (); ok {
i .Entities = val
}
}
func (*InputSingleMedia ) TypeID () uint32 {
return InputSingleMediaTypeID
}
func (*InputSingleMedia ) TypeName () string {
return "inputSingleMedia"
}
func (i *InputSingleMedia ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputSingleMedia" ,
ID : InputSingleMediaTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Media" ,
SchemaName : "media" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !i .Flags .Has (0 ),
},
}
return typ
}
func (i *InputSingleMedia ) SetFlags () {
if !(i .Entities == nil ) {
i .Flags .Set (0 )
}
}
func (i *InputSingleMedia ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputSingleMedia#1cc6e91f as nil" )
}
b .PutID (InputSingleMediaTypeID )
return i .EncodeBare (b )
}
func (i *InputSingleMedia ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputSingleMedia#1cc6e91f as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSingleMedia#1cc6e91f: field flags: %w" , err )
}
if i .Media == nil {
return fmt .Errorf ("unable to encode inputSingleMedia#1cc6e91f: field media is nil" )
}
if err := i .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSingleMedia#1cc6e91f: field media: %w" , err )
}
b .PutLong (i .RandomID )
b .PutString (i .Message )
if i .Flags .Has (0 ) {
b .PutVectorHeader (len (i .Entities ))
for idx , v := range i .Entities {
if v == nil {
return fmt .Errorf ("unable to encode inputSingleMedia#1cc6e91f: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputSingleMedia#1cc6e91f: field entities element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (i *InputSingleMedia ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputSingleMedia#1cc6e91f to nil" )
}
if err := b .ConsumeID (InputSingleMediaTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputSingleMedia ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputSingleMedia#1cc6e91f to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field flags: %w" , err )
}
}
{
value , err := DecodeInputMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field media: %w" , err )
}
i .Media = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field random_id: %w" , err )
}
i .RandomID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field message: %w" , err )
}
i .Message = value
}
if i .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field entities: %w" , err )
}
if headerLen > 0 {
i .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode inputSingleMedia#1cc6e91f: field entities: %w" , err )
}
i .Entities = append (i .Entities , value )
}
}
return nil
}
func (i *InputSingleMedia ) GetMedia () (value InputMediaClass ) {
if i == nil {
return
}
return i .Media
}
func (i *InputSingleMedia ) GetRandomID () (value int64 ) {
if i == nil {
return
}
return i .RandomID
}
func (i *InputSingleMedia ) GetMessage () (value string ) {
if i == nil {
return
}
return i .Message
}
func (i *InputSingleMedia ) SetEntities (value []MessageEntityClass ) {
i .Flags .Set (0 )
i .Entities = value
}
func (i *InputSingleMedia ) GetEntities () (value []MessageEntityClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .Entities , true
}
func (i *InputSingleMedia ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !i .Flags .Has (0 ) {
return value , false
}
return MessageEntityClassArray (i .Entities ), 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 .