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 BotInlineResult struct {
Flags bin .Fields
ID string
Type string
Title string
Description string
URL string
Thumb WebDocumentClass
Content WebDocumentClass
SendMessage BotInlineMessageClass
}
const BotInlineResultTypeID = 0x11965f3a
func (b BotInlineResult ) construct () BotInlineResultClass { return &b }
var (
_ bin .Encoder = &BotInlineResult {}
_ bin .Decoder = &BotInlineResult {}
_ bin .BareEncoder = &BotInlineResult {}
_ bin .BareDecoder = &BotInlineResult {}
_ BotInlineResultClass = &BotInlineResult {}
)
func (b *BotInlineResult ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .ID == "" ) {
return false
}
if !(b .Type == "" ) {
return false
}
if !(b .Title == "" ) {
return false
}
if !(b .Description == "" ) {
return false
}
if !(b .URL == "" ) {
return false
}
if !(b .Thumb == nil ) {
return false
}
if !(b .Content == nil ) {
return false
}
if !(b .SendMessage == nil ) {
return false
}
return true
}
func (b *BotInlineResult ) String () string {
if b == nil {
return "BotInlineResult(nil)"
}
type Alias BotInlineResult
return fmt .Sprintf ("BotInlineResult%+v" , Alias (*b ))
}
func (b *BotInlineResult ) FillFrom (from interface {
GetID () (value string )
GetType () (value string )
GetTitle () (value string , ok bool )
GetDescription () (value string , ok bool )
GetURL () (value string , ok bool )
GetThumb () (value WebDocumentClass , ok bool )
GetContent () (value WebDocumentClass , ok bool )
GetSendMessage () (value BotInlineMessageClass )
}) {
b .ID = from .GetID ()
b .Type = from .GetType ()
if val , ok := from .GetTitle (); ok {
b .Title = val
}
if val , ok := from .GetDescription (); ok {
b .Description = val
}
if val , ok := from .GetURL (); ok {
b .URL = val
}
if val , ok := from .GetThumb (); ok {
b .Thumb = val
}
if val , ok := from .GetContent (); ok {
b .Content = val
}
b .SendMessage = from .GetSendMessage ()
}
func (*BotInlineResult ) TypeID () uint32 {
return BotInlineResultTypeID
}
func (*BotInlineResult ) TypeName () string {
return "botInlineResult"
}
func (b *BotInlineResult ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botInlineResult" ,
ID : BotInlineResultTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "Description" ,
SchemaName : "description" ,
Null : !b .Flags .Has (2 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !b .Flags .Has (3 ),
},
{
Name : "Thumb" ,
SchemaName : "thumb" ,
Null : !b .Flags .Has (4 ),
},
{
Name : "Content" ,
SchemaName : "content" ,
Null : !b .Flags .Has (5 ),
},
{
Name : "SendMessage" ,
SchemaName : "send_message" ,
},
}
return typ
}
func (b *BotInlineResult ) SetFlags () {
if !(b .Title == "" ) {
b .Flags .Set (1 )
}
if !(b .Description == "" ) {
b .Flags .Set (2 )
}
if !(b .URL == "" ) {
b .Flags .Set (3 )
}
if !(b .Thumb == nil ) {
b .Flags .Set (4 )
}
if !(b .Content == nil ) {
b .Flags .Set (5 )
}
}
func (b *BotInlineResult ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botInlineResult#11965f3a as nil" )
}
buf .PutID (BotInlineResultTypeID )
return b .EncodeBare (buf )
}
func (b *BotInlineResult ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botInlineResult#11965f3a as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field flags: %w" , err )
}
buf .PutString (b .ID )
buf .PutString (b .Type )
if b .Flags .Has (1 ) {
buf .PutString (b .Title )
}
if b .Flags .Has (2 ) {
buf .PutString (b .Description )
}
if b .Flags .Has (3 ) {
buf .PutString (b .URL )
}
if b .Flags .Has (4 ) {
if b .Thumb == nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field thumb is nil" )
}
if err := b .Thumb .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field thumb: %w" , err )
}
}
if b .Flags .Has (5 ) {
if b .Content == nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field content is nil" )
}
if err := b .Content .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field content: %w" , err )
}
}
if b .SendMessage == nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field send_message is nil" )
}
if err := b .SendMessage .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineResult#11965f3a: field send_message: %w" , err )
}
return nil
}
func (b *BotInlineResult ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botInlineResult#11965f3a to nil" )
}
if err := buf .ConsumeID (BotInlineResultTypeID ); err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotInlineResult ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botInlineResult#11965f3a to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field flags: %w" , err )
}
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field id: %w" , err )
}
b .ID = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field type: %w" , err )
}
b .Type = value
}
if b .Flags .Has (1 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field title: %w" , err )
}
b .Title = value
}
if b .Flags .Has (2 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field description: %w" , err )
}
b .Description = value
}
if b .Flags .Has (3 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field url: %w" , err )
}
b .URL = value
}
if b .Flags .Has (4 ) {
value , err := DecodeWebDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field thumb: %w" , err )
}
b .Thumb = value
}
if b .Flags .Has (5 ) {
value , err := DecodeWebDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field content: %w" , err )
}
b .Content = value
}
{
value , err := DecodeBotInlineMessage (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineResult#11965f3a: field send_message: %w" , err )
}
b .SendMessage = value
}
return nil
}
func (b *BotInlineResult ) GetID () (value string ) {
if b == nil {
return
}
return b .ID
}
func (b *BotInlineResult ) GetType () (value string ) {
if b == nil {
return
}
return b .Type
}
func (b *BotInlineResult ) SetTitle (value string ) {
b .Flags .Set (1 )
b .Title = value
}
func (b *BotInlineResult ) GetTitle () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (1 ) {
return value , false
}
return b .Title , true
}
func (b *BotInlineResult ) SetDescription (value string ) {
b .Flags .Set (2 )
b .Description = value
}
func (b *BotInlineResult ) GetDescription () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .Description , true
}
func (b *BotInlineResult ) SetURL (value string ) {
b .Flags .Set (3 )
b .URL = value
}
func (b *BotInlineResult ) GetURL () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (3 ) {
return value , false
}
return b .URL , true
}
func (b *BotInlineResult ) SetThumb (value WebDocumentClass ) {
b .Flags .Set (4 )
b .Thumb = value
}
func (b *BotInlineResult ) GetThumb () (value WebDocumentClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (4 ) {
return value , false
}
return b .Thumb , true
}
func (b *BotInlineResult ) SetContent (value WebDocumentClass ) {
b .Flags .Set (5 )
b .Content = value
}
func (b *BotInlineResult ) GetContent () (value WebDocumentClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (5 ) {
return value , false
}
return b .Content , true
}
func (b *BotInlineResult ) GetSendMessage () (value BotInlineMessageClass ) {
if b == nil {
return
}
return b .SendMessage
}
type BotInlineMediaResult struct {
Flags bin .Fields
ID string
Type string
Photo PhotoClass
Document DocumentClass
Title string
Description string
SendMessage BotInlineMessageClass
}
const BotInlineMediaResultTypeID = 0x17db940b
func (b BotInlineMediaResult ) construct () BotInlineResultClass { return &b }
var (
_ bin .Encoder = &BotInlineMediaResult {}
_ bin .Decoder = &BotInlineMediaResult {}
_ bin .BareEncoder = &BotInlineMediaResult {}
_ bin .BareDecoder = &BotInlineMediaResult {}
_ BotInlineResultClass = &BotInlineMediaResult {}
)
func (b *BotInlineMediaResult ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .ID == "" ) {
return false
}
if !(b .Type == "" ) {
return false
}
if !(b .Photo == nil ) {
return false
}
if !(b .Document == nil ) {
return false
}
if !(b .Title == "" ) {
return false
}
if !(b .Description == "" ) {
return false
}
if !(b .SendMessage == nil ) {
return false
}
return true
}
func (b *BotInlineMediaResult ) String () string {
if b == nil {
return "BotInlineMediaResult(nil)"
}
type Alias BotInlineMediaResult
return fmt .Sprintf ("BotInlineMediaResult%+v" , Alias (*b ))
}
func (b *BotInlineMediaResult ) FillFrom (from interface {
GetID () (value string )
GetType () (value string )
GetPhoto () (value PhotoClass , ok bool )
GetDocument () (value DocumentClass , ok bool )
GetTitle () (value string , ok bool )
GetDescription () (value string , ok bool )
GetSendMessage () (value BotInlineMessageClass )
}) {
b .ID = from .GetID ()
b .Type = from .GetType ()
if val , ok := from .GetPhoto (); ok {
b .Photo = val
}
if val , ok := from .GetDocument (); ok {
b .Document = val
}
if val , ok := from .GetTitle (); ok {
b .Title = val
}
if val , ok := from .GetDescription (); ok {
b .Description = val
}
b .SendMessage = from .GetSendMessage ()
}
func (*BotInlineMediaResult ) TypeID () uint32 {
return BotInlineMediaResultTypeID
}
func (*BotInlineMediaResult ) TypeName () string {
return "botInlineMediaResult"
}
func (b *BotInlineMediaResult ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botInlineMediaResult" ,
ID : BotInlineMediaResultTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "Photo" ,
SchemaName : "photo" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !b .Flags .Has (2 ),
},
{
Name : "Description" ,
SchemaName : "description" ,
Null : !b .Flags .Has (3 ),
},
{
Name : "SendMessage" ,
SchemaName : "send_message" ,
},
}
return typ
}
func (b *BotInlineMediaResult ) SetFlags () {
if !(b .Photo == nil ) {
b .Flags .Set (0 )
}
if !(b .Document == nil ) {
b .Flags .Set (1 )
}
if !(b .Title == "" ) {
b .Flags .Set (2 )
}
if !(b .Description == "" ) {
b .Flags .Set (3 )
}
}
func (b *BotInlineMediaResult ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botInlineMediaResult#17db940b as nil" )
}
buf .PutID (BotInlineMediaResultTypeID )
return b .EncodeBare (buf )
}
func (b *BotInlineMediaResult ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botInlineMediaResult#17db940b as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field flags: %w" , err )
}
buf .PutString (b .ID )
buf .PutString (b .Type )
if b .Flags .Has (0 ) {
if b .Photo == nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field photo is nil" )
}
if err := b .Photo .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field photo: %w" , err )
}
}
if b .Flags .Has (1 ) {
if b .Document == nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field document is nil" )
}
if err := b .Document .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field document: %w" , err )
}
}
if b .Flags .Has (2 ) {
buf .PutString (b .Title )
}
if b .Flags .Has (3 ) {
buf .PutString (b .Description )
}
if b .SendMessage == nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field send_message is nil" )
}
if err := b .SendMessage .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botInlineMediaResult#17db940b: field send_message: %w" , err )
}
return nil
}
func (b *BotInlineMediaResult ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botInlineMediaResult#17db940b to nil" )
}
if err := buf .ConsumeID (BotInlineMediaResultTypeID ); err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotInlineMediaResult ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botInlineMediaResult#17db940b to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field flags: %w" , err )
}
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field id: %w" , err )
}
b .ID = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field type: %w" , err )
}
b .Type = value
}
if b .Flags .Has (0 ) {
value , err := DecodePhoto (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field photo: %w" , err )
}
b .Photo = value
}
if b .Flags .Has (1 ) {
value , err := DecodeDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field document: %w" , err )
}
b .Document = value
}
if b .Flags .Has (2 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field title: %w" , err )
}
b .Title = value
}
if b .Flags .Has (3 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field description: %w" , err )
}
b .Description = value
}
{
value , err := DecodeBotInlineMessage (buf )
if err != nil {
return fmt .Errorf ("unable to decode botInlineMediaResult#17db940b: field send_message: %w" , err )
}
b .SendMessage = value
}
return nil
}
func (b *BotInlineMediaResult ) GetID () (value string ) {
if b == nil {
return
}
return b .ID
}
func (b *BotInlineMediaResult ) GetType () (value string ) {
if b == nil {
return
}
return b .Type
}
func (b *BotInlineMediaResult ) SetPhoto (value PhotoClass ) {
b .Flags .Set (0 )
b .Photo = value
}
func (b *BotInlineMediaResult ) GetPhoto () (value PhotoClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .Photo , true
}
func (b *BotInlineMediaResult ) SetDocument (value DocumentClass ) {
b .Flags .Set (1 )
b .Document = value
}
func (b *BotInlineMediaResult ) GetDocument () (value DocumentClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (1 ) {
return value , false
}
return b .Document , true
}
func (b *BotInlineMediaResult ) SetTitle (value string ) {
b .Flags .Set (2 )
b .Title = value
}
func (b *BotInlineMediaResult ) GetTitle () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .Title , true
}
func (b *BotInlineMediaResult ) SetDescription (value string ) {
b .Flags .Set (3 )
b .Description = value
}
func (b *BotInlineMediaResult ) GetDescription () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (3 ) {
return value , false
}
return b .Description , true
}
func (b *BotInlineMediaResult ) GetSendMessage () (value BotInlineMessageClass ) {
if b == nil {
return
}
return b .SendMessage
}
const BotInlineResultClassName = "BotInlineResult"
type BotInlineResultClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () BotInlineResultClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value string )
GetType () (value string )
GetTitle () (value string , ok bool )
GetDescription () (value string , ok bool )
GetSendMessage () (value BotInlineMessageClass )
}
func DecodeBotInlineResult (buf *bin .Buffer ) (BotInlineResultClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case BotInlineResultTypeID :
v := BotInlineResult {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotInlineResultClass: %w" , err )
}
return &v , nil
case BotInlineMediaResultTypeID :
v := BotInlineMediaResult {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotInlineResultClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode BotInlineResultClass: %w" , bin .NewUnexpectedID (id ))
}
}
type BotInlineResultBox struct {
BotInlineResult BotInlineResultClass
}
func (b *BotInlineResultBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode BotInlineResultBox to nil" )
}
v , err := DecodeBotInlineResult (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .BotInlineResult = v
return nil
}
func (b *BotInlineResultBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .BotInlineResult == nil {
return fmt .Errorf ("unable to encode BotInlineResultClass as nil" )
}
return b .BotInlineResult .Encode (buf )
}
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 .