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 MessagesSetBotCallbackAnswerRequest struct {
Flags bin .Fields
Alert bool
QueryID int64
Message string
URL string
CacheTime int
}
const MessagesSetBotCallbackAnswerRequestTypeID = 0xd58f130a
var (
_ bin .Encoder = &MessagesSetBotCallbackAnswerRequest {}
_ bin .Decoder = &MessagesSetBotCallbackAnswerRequest {}
_ bin .BareEncoder = &MessagesSetBotCallbackAnswerRequest {}
_ bin .BareDecoder = &MessagesSetBotCallbackAnswerRequest {}
)
func (s *MessagesSetBotCallbackAnswerRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Alert == false ) {
return false
}
if !(s .QueryID == 0 ) {
return false
}
if !(s .Message == "" ) {
return false
}
if !(s .URL == "" ) {
return false
}
if !(s .CacheTime == 0 ) {
return false
}
return true
}
func (s *MessagesSetBotCallbackAnswerRequest ) String () string {
if s == nil {
return "MessagesSetBotCallbackAnswerRequest(nil)"
}
type Alias MessagesSetBotCallbackAnswerRequest
return fmt .Sprintf ("MessagesSetBotCallbackAnswerRequest%+v" , Alias (*s ))
}
func (s *MessagesSetBotCallbackAnswerRequest ) FillFrom (from interface {
GetAlert () (value bool )
GetQueryID () (value int64 )
GetMessage () (value string , ok bool )
GetURL () (value string , ok bool )
GetCacheTime () (value int )
}) {
s .Alert = from .GetAlert ()
s .QueryID = from .GetQueryID ()
if val , ok := from .GetMessage (); ok {
s .Message = val
}
if val , ok := from .GetURL (); ok {
s .URL = val
}
s .CacheTime = from .GetCacheTime ()
}
func (*MessagesSetBotCallbackAnswerRequest ) TypeID () uint32 {
return MessagesSetBotCallbackAnswerRequestTypeID
}
func (*MessagesSetBotCallbackAnswerRequest ) TypeName () string {
return "messages.setBotCallbackAnswer"
}
func (s *MessagesSetBotCallbackAnswerRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setBotCallbackAnswer" ,
ID : MessagesSetBotCallbackAnswerRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Alert" ,
SchemaName : "alert" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "QueryID" ,
SchemaName : "query_id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "CacheTime" ,
SchemaName : "cache_time" ,
},
}
return typ
}
func (s *MessagesSetBotCallbackAnswerRequest ) SetFlags () {
if !(s .Alert == false ) {
s .Flags .Set (1 )
}
if !(s .Message == "" ) {
s .Flags .Set (0 )
}
if !(s .URL == "" ) {
s .Flags .Set (2 )
}
}
func (s *MessagesSetBotCallbackAnswerRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setBotCallbackAnswer#d58f130a as nil" )
}
b .PutID (MessagesSetBotCallbackAnswerRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetBotCallbackAnswerRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setBotCallbackAnswer#d58f130a as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setBotCallbackAnswer#d58f130a: field flags: %w" , err )
}
b .PutLong (s .QueryID )
if s .Flags .Has (0 ) {
b .PutString (s .Message )
}
if s .Flags .Has (2 ) {
b .PutString (s .URL )
}
b .PutInt (s .CacheTime )
return nil
}
func (s *MessagesSetBotCallbackAnswerRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setBotCallbackAnswer#d58f130a to nil" )
}
if err := b .ConsumeID (MessagesSetBotCallbackAnswerRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetBotCallbackAnswerRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setBotCallbackAnswer#d58f130a to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: field flags: %w" , err )
}
}
s .Alert = s .Flags .Has (1 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: field query_id: %w" , err )
}
s .QueryID = value
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: field message: %w" , err )
}
s .Message = value
}
if s .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: field url: %w" , err )
}
s .URL = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setBotCallbackAnswer#d58f130a: field cache_time: %w" , err )
}
s .CacheTime = value
}
return nil
}
func (s *MessagesSetBotCallbackAnswerRequest ) SetAlert (value bool ) {
if value {
s .Flags .Set (1 )
s .Alert = true
} else {
s .Flags .Unset (1 )
s .Alert = false
}
}
func (s *MessagesSetBotCallbackAnswerRequest ) GetAlert () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSetBotCallbackAnswerRequest ) GetQueryID () (value int64 ) {
if s == nil {
return
}
return s .QueryID
}
func (s *MessagesSetBotCallbackAnswerRequest ) SetMessage (value string ) {
s .Flags .Set (0 )
s .Message = value
}
func (s *MessagesSetBotCallbackAnswerRequest ) GetMessage () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Message , true
}
func (s *MessagesSetBotCallbackAnswerRequest ) SetURL (value string ) {
s .Flags .Set (2 )
s .URL = value
}
func (s *MessagesSetBotCallbackAnswerRequest ) GetURL () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .URL , true
}
func (s *MessagesSetBotCallbackAnswerRequest ) GetCacheTime () (value int ) {
if s == nil {
return
}
return s .CacheTime
}
func (c *Client ) MessagesSetBotCallbackAnswer (ctx context .Context , request *MessagesSetBotCallbackAnswerRequest ) (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 .