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 MessagesToggleBotInAttachMenuRequest struct {
Flags bin .Fields
WriteAllowed bool
Bot InputUserClass
Enabled bool
}
const MessagesToggleBotInAttachMenuRequestTypeID = 0x69f59d69
var (
_ bin .Encoder = &MessagesToggleBotInAttachMenuRequest {}
_ bin .Decoder = &MessagesToggleBotInAttachMenuRequest {}
_ bin .BareEncoder = &MessagesToggleBotInAttachMenuRequest {}
_ bin .BareDecoder = &MessagesToggleBotInAttachMenuRequest {}
)
func (t *MessagesToggleBotInAttachMenuRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .WriteAllowed == false ) {
return false
}
if !(t .Bot == nil ) {
return false
}
if !(t .Enabled == false ) {
return false
}
return true
}
func (t *MessagesToggleBotInAttachMenuRequest ) String () string {
if t == nil {
return "MessagesToggleBotInAttachMenuRequest(nil)"
}
type Alias MessagesToggleBotInAttachMenuRequest
return fmt .Sprintf ("MessagesToggleBotInAttachMenuRequest%+v" , Alias (*t ))
}
func (t *MessagesToggleBotInAttachMenuRequest ) FillFrom (from interface {
GetWriteAllowed () (value bool )
GetBot () (value InputUserClass )
GetEnabled () (value bool )
}) {
t .WriteAllowed = from .GetWriteAllowed ()
t .Bot = from .GetBot ()
t .Enabled = from .GetEnabled ()
}
func (*MessagesToggleBotInAttachMenuRequest ) TypeID () uint32 {
return MessagesToggleBotInAttachMenuRequestTypeID
}
func (*MessagesToggleBotInAttachMenuRequest ) TypeName () string {
return "messages.toggleBotInAttachMenu"
}
func (t *MessagesToggleBotInAttachMenuRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.toggleBotInAttachMenu" ,
ID : MessagesToggleBotInAttachMenuRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "WriteAllowed" ,
SchemaName : "write_allowed" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Enabled" ,
SchemaName : "enabled" ,
},
}
return typ
}
func (t *MessagesToggleBotInAttachMenuRequest ) SetFlags () {
if !(t .WriteAllowed == false ) {
t .Flags .Set (0 )
}
}
func (t *MessagesToggleBotInAttachMenuRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil" )
}
b .PutID (MessagesToggleBotInAttachMenuRequestTypeID )
return t .EncodeBare (b )
}
func (t *MessagesToggleBotInAttachMenuRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.toggleBotInAttachMenu#69f59d69: field flags: %w" , err )
}
if t .Bot == nil {
return fmt .Errorf ("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot is nil" )
}
if err := t .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot: %w" , err )
}
b .PutBool (t .Enabled )
return nil
}
func (t *MessagesToggleBotInAttachMenuRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil" )
}
if err := b .ConsumeID (MessagesToggleBotInAttachMenuRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.toggleBotInAttachMenu#69f59d69: %w" , err )
}
return t .DecodeBare (b )
}
func (t *MessagesToggleBotInAttachMenuRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.toggleBotInAttachMenu#69f59d69: field flags: %w" , err )
}
}
t .WriteAllowed = t .Flags .Has (0 )
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.toggleBotInAttachMenu#69f59d69: field bot: %w" , err )
}
t .Bot = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode messages.toggleBotInAttachMenu#69f59d69: field enabled: %w" , err )
}
t .Enabled = value
}
return nil
}
func (t *MessagesToggleBotInAttachMenuRequest ) SetWriteAllowed (value bool ) {
if value {
t .Flags .Set (0 )
t .WriteAllowed = true
} else {
t .Flags .Unset (0 )
t .WriteAllowed = false
}
}
func (t *MessagesToggleBotInAttachMenuRequest ) GetWriteAllowed () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (0 )
}
func (t *MessagesToggleBotInAttachMenuRequest ) GetBot () (value InputUserClass ) {
if t == nil {
return
}
return t .Bot
}
func (t *MessagesToggleBotInAttachMenuRequest ) GetEnabled () (value bool ) {
if t == nil {
return
}
return t .Enabled
}
func (c *Client ) MessagesToggleBotInAttachMenu (ctx context .Context , request *MessagesToggleBotInAttachMenuRequest ) (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 .