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 MessagesSetInlineBotResultsRequest struct {
Flags bin .Fields
Gallery bool
Private bool
QueryID int64
Results []InputBotInlineResultClass
CacheTime int
NextOffset string
SwitchPm InlineBotSwitchPM
SwitchWebview InlineBotWebView
}
const MessagesSetInlineBotResultsRequestTypeID = 0xbb12a419
var (
_ bin .Encoder = &MessagesSetInlineBotResultsRequest {}
_ bin .Decoder = &MessagesSetInlineBotResultsRequest {}
_ bin .BareEncoder = &MessagesSetInlineBotResultsRequest {}
_ bin .BareDecoder = &MessagesSetInlineBotResultsRequest {}
)
func (s *MessagesSetInlineBotResultsRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Gallery == false ) {
return false
}
if !(s .Private == false ) {
return false
}
if !(s .QueryID == 0 ) {
return false
}
if !(s .Results == nil ) {
return false
}
if !(s .CacheTime == 0 ) {
return false
}
if !(s .NextOffset == "" ) {
return false
}
if !(s .SwitchPm .Zero ()) {
return false
}
if !(s .SwitchWebview .Zero ()) {
return false
}
return true
}
func (s *MessagesSetInlineBotResultsRequest ) String () string {
if s == nil {
return "MessagesSetInlineBotResultsRequest(nil)"
}
type Alias MessagesSetInlineBotResultsRequest
return fmt .Sprintf ("MessagesSetInlineBotResultsRequest%+v" , Alias (*s ))
}
func (s *MessagesSetInlineBotResultsRequest ) FillFrom (from interface {
GetGallery () (value bool )
GetPrivate () (value bool )
GetQueryID () (value int64 )
GetResults () (value []InputBotInlineResultClass )
GetCacheTime () (value int )
GetNextOffset () (value string , ok bool )
GetSwitchPm () (value InlineBotSwitchPM , ok bool )
GetSwitchWebview () (value InlineBotWebView , ok bool )
}) {
s .Gallery = from .GetGallery ()
s .Private = from .GetPrivate ()
s .QueryID = from .GetQueryID ()
s .Results = from .GetResults ()
s .CacheTime = from .GetCacheTime ()
if val , ok := from .GetNextOffset (); ok {
s .NextOffset = val
}
if val , ok := from .GetSwitchPm (); ok {
s .SwitchPm = val
}
if val , ok := from .GetSwitchWebview (); ok {
s .SwitchWebview = val
}
}
func (*MessagesSetInlineBotResultsRequest ) TypeID () uint32 {
return MessagesSetInlineBotResultsRequestTypeID
}
func (*MessagesSetInlineBotResultsRequest ) TypeName () string {
return "messages.setInlineBotResults"
}
func (s *MessagesSetInlineBotResultsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setInlineBotResults" ,
ID : MessagesSetInlineBotResultsRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Gallery" ,
SchemaName : "gallery" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Private" ,
SchemaName : "private" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "QueryID" ,
SchemaName : "query_id" ,
},
{
Name : "Results" ,
SchemaName : "results" ,
},
{
Name : "CacheTime" ,
SchemaName : "cache_time" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "SwitchPm" ,
SchemaName : "switch_pm" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "SwitchWebview" ,
SchemaName : "switch_webview" ,
Null : !s .Flags .Has (4 ),
},
}
return typ
}
func (s *MessagesSetInlineBotResultsRequest ) SetFlags () {
if !(s .Gallery == false ) {
s .Flags .Set (0 )
}
if !(s .Private == false ) {
s .Flags .Set (1 )
}
if !(s .NextOffset == "" ) {
s .Flags .Set (2 )
}
if !(s .SwitchPm .Zero ()) {
s .Flags .Set (3 )
}
if !(s .SwitchWebview .Zero ()) {
s .Flags .Set (4 )
}
}
func (s *MessagesSetInlineBotResultsRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setInlineBotResults#bb12a419 as nil" )
}
b .PutID (MessagesSetInlineBotResultsRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetInlineBotResultsRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setInlineBotResults#bb12a419 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setInlineBotResults#bb12a419: field flags: %w" , err )
}
b .PutLong (s .QueryID )
b .PutVectorHeader (len (s .Results ))
for idx , v := range s .Results {
if v == nil {
return fmt .Errorf ("unable to encode messages.setInlineBotResults#bb12a419: field results element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setInlineBotResults#bb12a419: field results element with index %d: %w" , idx , err )
}
}
b .PutInt (s .CacheTime )
if s .Flags .Has (2 ) {
b .PutString (s .NextOffset )
}
if s .Flags .Has (3 ) {
if err := s .SwitchPm .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setInlineBotResults#bb12a419: field switch_pm: %w" , err )
}
}
if s .Flags .Has (4 ) {
if err := s .SwitchWebview .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setInlineBotResults#bb12a419: field switch_webview: %w" , err )
}
}
return nil
}
func (s *MessagesSetInlineBotResultsRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setInlineBotResults#bb12a419 to nil" )
}
if err := b .ConsumeID (MessagesSetInlineBotResultsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetInlineBotResultsRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setInlineBotResults#bb12a419 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field flags: %w" , err )
}
}
s .Gallery = s .Flags .Has (0 )
s .Private = s .Flags .Has (1 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field query_id: %w" , err )
}
s .QueryID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field results: %w" , err )
}
if headerLen > 0 {
s .Results = make ([]InputBotInlineResultClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputBotInlineResult (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field results: %w" , err )
}
s .Results = append (s .Results , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field cache_time: %w" , err )
}
s .CacheTime = value
}
if s .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field next_offset: %w" , err )
}
s .NextOffset = value
}
if s .Flags .Has (3 ) {
if err := s .SwitchPm .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field switch_pm: %w" , err )
}
}
if s .Flags .Has (4 ) {
if err := s .SwitchWebview .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setInlineBotResults#bb12a419: field switch_webview: %w" , err )
}
}
return nil
}
func (s *MessagesSetInlineBotResultsRequest ) SetGallery (value bool ) {
if value {
s .Flags .Set (0 )
s .Gallery = true
} else {
s .Flags .Unset (0 )
s .Gallery = false
}
}
func (s *MessagesSetInlineBotResultsRequest ) GetGallery () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *MessagesSetInlineBotResultsRequest ) SetPrivate (value bool ) {
if value {
s .Flags .Set (1 )
s .Private = true
} else {
s .Flags .Unset (1 )
s .Private = false
}
}
func (s *MessagesSetInlineBotResultsRequest ) GetPrivate () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSetInlineBotResultsRequest ) GetQueryID () (value int64 ) {
if s == nil {
return
}
return s .QueryID
}
func (s *MessagesSetInlineBotResultsRequest ) GetResults () (value []InputBotInlineResultClass ) {
if s == nil {
return
}
return s .Results
}
func (s *MessagesSetInlineBotResultsRequest ) GetCacheTime () (value int ) {
if s == nil {
return
}
return s .CacheTime
}
func (s *MessagesSetInlineBotResultsRequest ) SetNextOffset (value string ) {
s .Flags .Set (2 )
s .NextOffset = value
}
func (s *MessagesSetInlineBotResultsRequest ) GetNextOffset () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .NextOffset , true
}
func (s *MessagesSetInlineBotResultsRequest ) SetSwitchPm (value InlineBotSwitchPM ) {
s .Flags .Set (3 )
s .SwitchPm = value
}
func (s *MessagesSetInlineBotResultsRequest ) GetSwitchPm () (value InlineBotSwitchPM , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (3 ) {
return value , false
}
return s .SwitchPm , true
}
func (s *MessagesSetInlineBotResultsRequest ) SetSwitchWebview (value InlineBotWebView ) {
s .Flags .Set (4 )
s .SwitchWebview = value
}
func (s *MessagesSetInlineBotResultsRequest ) GetSwitchWebview () (value InlineBotWebView , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (4 ) {
return value , false
}
return s .SwitchWebview , true
}
func (s *MessagesSetInlineBotResultsRequest ) MapResults () (value InputBotInlineResultClassArray ) {
return InputBotInlineResultClassArray (s .Results )
}
func (c *Client ) MessagesSetInlineBotResults (ctx context .Context , request *MessagesSetInlineBotResultsRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
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 .