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 MessagesBotResults struct {
Flags bin .Fields
Gallery bool
QueryID int64
NextOffset string
SwitchPm InlineBotSwitchPM
SwitchWebview InlineBotWebView
Results []BotInlineResultClass
CacheTime int
Users []UserClass
}
const MessagesBotResultsTypeID = 0xe021f2f6
var (
_ bin .Encoder = &MessagesBotResults {}
_ bin .Decoder = &MessagesBotResults {}
_ bin .BareEncoder = &MessagesBotResults {}
_ bin .BareDecoder = &MessagesBotResults {}
)
func (b *MessagesBotResults ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Gallery == false ) {
return false
}
if !(b .QueryID == 0 ) {
return false
}
if !(b .NextOffset == "" ) {
return false
}
if !(b .SwitchPm .Zero ()) {
return false
}
if !(b .SwitchWebview .Zero ()) {
return false
}
if !(b .Results == nil ) {
return false
}
if !(b .CacheTime == 0 ) {
return false
}
if !(b .Users == nil ) {
return false
}
return true
}
func (b *MessagesBotResults ) String () string {
if b == nil {
return "MessagesBotResults(nil)"
}
type Alias MessagesBotResults
return fmt .Sprintf ("MessagesBotResults%+v" , Alias (*b ))
}
func (b *MessagesBotResults ) FillFrom (from interface {
GetGallery () (value bool )
GetQueryID () (value int64 )
GetNextOffset () (value string , ok bool )
GetSwitchPm () (value InlineBotSwitchPM , ok bool )
GetSwitchWebview () (value InlineBotWebView , ok bool )
GetResults () (value []BotInlineResultClass )
GetCacheTime () (value int )
GetUsers () (value []UserClass )
}) {
b .Gallery = from .GetGallery ()
b .QueryID = from .GetQueryID ()
if val , ok := from .GetNextOffset (); ok {
b .NextOffset = val
}
if val , ok := from .GetSwitchPm (); ok {
b .SwitchPm = val
}
if val , ok := from .GetSwitchWebview (); ok {
b .SwitchWebview = val
}
b .Results = from .GetResults ()
b .CacheTime = from .GetCacheTime ()
b .Users = from .GetUsers ()
}
func (*MessagesBotResults ) TypeID () uint32 {
return MessagesBotResultsTypeID
}
func (*MessagesBotResults ) TypeName () string {
return "messages.botResults"
}
func (b *MessagesBotResults ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.botResults" ,
ID : MessagesBotResultsTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Gallery" ,
SchemaName : "gallery" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "QueryID" ,
SchemaName : "query_id" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "SwitchPm" ,
SchemaName : "switch_pm" ,
Null : !b .Flags .Has (2 ),
},
{
Name : "SwitchWebview" ,
SchemaName : "switch_webview" ,
Null : !b .Flags .Has (3 ),
},
{
Name : "Results" ,
SchemaName : "results" ,
},
{
Name : "CacheTime" ,
SchemaName : "cache_time" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (b *MessagesBotResults ) SetFlags () {
if !(b .Gallery == false ) {
b .Flags .Set (0 )
}
if !(b .NextOffset == "" ) {
b .Flags .Set (1 )
}
if !(b .SwitchPm .Zero ()) {
b .Flags .Set (2 )
}
if !(b .SwitchWebview .Zero ()) {
b .Flags .Set (3 )
}
}
func (b *MessagesBotResults ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode messages.botResults#e021f2f6 as nil" )
}
buf .PutID (MessagesBotResultsTypeID )
return b .EncodeBare (buf )
}
func (b *MessagesBotResults ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode messages.botResults#e021f2f6 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field flags: %w" , err )
}
buf .PutLong (b .QueryID )
if b .Flags .Has (1 ) {
buf .PutString (b .NextOffset )
}
if b .Flags .Has (2 ) {
if err := b .SwitchPm .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field switch_pm: %w" , err )
}
}
if b .Flags .Has (3 ) {
if err := b .SwitchWebview .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field switch_webview: %w" , err )
}
}
buf .PutVectorHeader (len (b .Results ))
for idx , v := range b .Results {
if v == nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field results element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field results element with index %d: %w" , idx , err )
}
}
buf .PutInt (b .CacheTime )
buf .PutVectorHeader (len (b .Users ))
for idx , v := range b .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field users element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botResults#e021f2f6: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (b *MessagesBotResults ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode messages.botResults#e021f2f6 to nil" )
}
if err := buf .ConsumeID (MessagesBotResultsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *MessagesBotResults ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode messages.botResults#e021f2f6 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field flags: %w" , err )
}
}
b .Gallery = b .Flags .Has (0 )
{
value , err := buf .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field query_id: %w" , err )
}
b .QueryID = value
}
if b .Flags .Has (1 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field next_offset: %w" , err )
}
b .NextOffset = value
}
if b .Flags .Has (2 ) {
if err := b .SwitchPm .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field switch_pm: %w" , err )
}
}
if b .Flags .Has (3 ) {
if err := b .SwitchWebview .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field switch_webview: %w" , err )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field results: %w" , err )
}
if headerLen > 0 {
b .Results = make ([]BotInlineResultClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeBotInlineResult (buf )
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field results: %w" , err )
}
b .Results = append (b .Results , value )
}
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field cache_time: %w" , err )
}
b .CacheTime = value
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field users: %w" , err )
}
if headerLen > 0 {
b .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode messages.botResults#e021f2f6: field users: %w" , err )
}
b .Users = append (b .Users , value )
}
}
return nil
}
func (b *MessagesBotResults ) SetGallery (value bool ) {
if value {
b .Flags .Set (0 )
b .Gallery = true
} else {
b .Flags .Unset (0 )
b .Gallery = false
}
}
func (b *MessagesBotResults ) GetGallery () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (0 )
}
func (b *MessagesBotResults ) GetQueryID () (value int64 ) {
if b == nil {
return
}
return b .QueryID
}
func (b *MessagesBotResults ) SetNextOffset (value string ) {
b .Flags .Set (1 )
b .NextOffset = value
}
func (b *MessagesBotResults ) GetNextOffset () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (1 ) {
return value , false
}
return b .NextOffset , true
}
func (b *MessagesBotResults ) SetSwitchPm (value InlineBotSwitchPM ) {
b .Flags .Set (2 )
b .SwitchPm = value
}
func (b *MessagesBotResults ) GetSwitchPm () (value InlineBotSwitchPM , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .SwitchPm , true
}
func (b *MessagesBotResults ) SetSwitchWebview (value InlineBotWebView ) {
b .Flags .Set (3 )
b .SwitchWebview = value
}
func (b *MessagesBotResults ) GetSwitchWebview () (value InlineBotWebView , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (3 ) {
return value , false
}
return b .SwitchWebview , true
}
func (b *MessagesBotResults ) GetResults () (value []BotInlineResultClass ) {
if b == nil {
return
}
return b .Results
}
func (b *MessagesBotResults ) GetCacheTime () (value int ) {
if b == nil {
return
}
return b .CacheTime
}
func (b *MessagesBotResults ) GetUsers () (value []UserClass ) {
if b == nil {
return
}
return b .Users
}
func (b *MessagesBotResults ) MapResults () (value BotInlineResultClassArray ) {
return BotInlineResultClassArray (b .Results )
}
func (b *MessagesBotResults ) MapUsers () (value UserClassArray ) {
return UserClassArray (b .Users )
}
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 .