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 MessagesBotCallbackAnswer struct {
Flags bin .Fields
Alert bool
HasURL bool
NativeUI bool
Message string
URL string
CacheTime int
}
const MessagesBotCallbackAnswerTypeID = 0x36585ea4
var (
_ bin .Encoder = &MessagesBotCallbackAnswer {}
_ bin .Decoder = &MessagesBotCallbackAnswer {}
_ bin .BareEncoder = &MessagesBotCallbackAnswer {}
_ bin .BareDecoder = &MessagesBotCallbackAnswer {}
)
func (b *MessagesBotCallbackAnswer ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .Alert == false ) {
return false
}
if !(b .HasURL == false ) {
return false
}
if !(b .NativeUI == false ) {
return false
}
if !(b .Message == "" ) {
return false
}
if !(b .URL == "" ) {
return false
}
if !(b .CacheTime == 0 ) {
return false
}
return true
}
func (b *MessagesBotCallbackAnswer ) String () string {
if b == nil {
return "MessagesBotCallbackAnswer(nil)"
}
type Alias MessagesBotCallbackAnswer
return fmt .Sprintf ("MessagesBotCallbackAnswer%+v" , Alias (*b ))
}
func (b *MessagesBotCallbackAnswer ) FillFrom (from interface {
GetAlert () (value bool )
GetHasURL () (value bool )
GetNativeUI () (value bool )
GetMessage () (value string , ok bool )
GetURL () (value string , ok bool )
GetCacheTime () (value int )
}) {
b .Alert = from .GetAlert ()
b .HasURL = from .GetHasURL ()
b .NativeUI = from .GetNativeUI ()
if val , ok := from .GetMessage (); ok {
b .Message = val
}
if val , ok := from .GetURL (); ok {
b .URL = val
}
b .CacheTime = from .GetCacheTime ()
}
func (*MessagesBotCallbackAnswer ) TypeID () uint32 {
return MessagesBotCallbackAnswerTypeID
}
func (*MessagesBotCallbackAnswer ) TypeName () string {
return "messages.botCallbackAnswer"
}
func (b *MessagesBotCallbackAnswer ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.botCallbackAnswer" ,
ID : MessagesBotCallbackAnswerTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Alert" ,
SchemaName : "alert" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "HasURL" ,
SchemaName : "has_url" ,
Null : !b .Flags .Has (3 ),
},
{
Name : "NativeUI" ,
SchemaName : "native_ui" ,
Null : !b .Flags .Has (4 ),
},
{
Name : "Message" ,
SchemaName : "message" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !b .Flags .Has (2 ),
},
{
Name : "CacheTime" ,
SchemaName : "cache_time" ,
},
}
return typ
}
func (b *MessagesBotCallbackAnswer ) SetFlags () {
if !(b .Alert == false ) {
b .Flags .Set (1 )
}
if !(b .HasURL == false ) {
b .Flags .Set (3 )
}
if !(b .NativeUI == false ) {
b .Flags .Set (4 )
}
if !(b .Message == "" ) {
b .Flags .Set (0 )
}
if !(b .URL == "" ) {
b .Flags .Set (2 )
}
}
func (b *MessagesBotCallbackAnswer ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode messages.botCallbackAnswer#36585ea4 as nil" )
}
buf .PutID (MessagesBotCallbackAnswerTypeID )
return b .EncodeBare (buf )
}
func (b *MessagesBotCallbackAnswer ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode messages.botCallbackAnswer#36585ea4 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode messages.botCallbackAnswer#36585ea4: field flags: %w" , err )
}
if b .Flags .Has (0 ) {
buf .PutString (b .Message )
}
if b .Flags .Has (2 ) {
buf .PutString (b .URL )
}
buf .PutInt (b .CacheTime )
return nil
}
func (b *MessagesBotCallbackAnswer ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode messages.botCallbackAnswer#36585ea4 to nil" )
}
if err := buf .ConsumeID (MessagesBotCallbackAnswerTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.botCallbackAnswer#36585ea4: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *MessagesBotCallbackAnswer ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode messages.botCallbackAnswer#36585ea4 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode messages.botCallbackAnswer#36585ea4: field flags: %w" , err )
}
}
b .Alert = b .Flags .Has (1 )
b .HasURL = b .Flags .Has (3 )
b .NativeUI = b .Flags .Has (4 )
if b .Flags .Has (0 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botCallbackAnswer#36585ea4: field message: %w" , err )
}
b .Message = value
}
if b .Flags .Has (2 ) {
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botCallbackAnswer#36585ea4: field url: %w" , err )
}
b .URL = value
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.botCallbackAnswer#36585ea4: field cache_time: %w" , err )
}
b .CacheTime = value
}
return nil
}
func (b *MessagesBotCallbackAnswer ) SetAlert (value bool ) {
if value {
b .Flags .Set (1 )
b .Alert = true
} else {
b .Flags .Unset (1 )
b .Alert = false
}
}
func (b *MessagesBotCallbackAnswer ) GetAlert () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (1 )
}
func (b *MessagesBotCallbackAnswer ) SetHasURL (value bool ) {
if value {
b .Flags .Set (3 )
b .HasURL = true
} else {
b .Flags .Unset (3 )
b .HasURL = false
}
}
func (b *MessagesBotCallbackAnswer ) GetHasURL () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (3 )
}
func (b *MessagesBotCallbackAnswer ) SetNativeUI (value bool ) {
if value {
b .Flags .Set (4 )
b .NativeUI = true
} else {
b .Flags .Unset (4 )
b .NativeUI = false
}
}
func (b *MessagesBotCallbackAnswer ) GetNativeUI () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (4 )
}
func (b *MessagesBotCallbackAnswer ) SetMessage (value string ) {
b .Flags .Set (0 )
b .Message = value
}
func (b *MessagesBotCallbackAnswer ) GetMessage () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .Message , true
}
func (b *MessagesBotCallbackAnswer ) SetURL (value string ) {
b .Flags .Set (2 )
b .URL = value
}
func (b *MessagesBotCallbackAnswer ) GetURL () (value string , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .URL , true
}
func (b *MessagesBotCallbackAnswer ) GetCacheTime () (value int ) {
if b == nil {
return
}
return b .CacheTime
}
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 .