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 MessagesTogglePeerTranslationsRequest struct {
Flags bin .Fields
Disabled bool
Peer InputPeerClass
}
const MessagesTogglePeerTranslationsRequestTypeID = 0xe47cb579
var (
_ bin .Encoder = &MessagesTogglePeerTranslationsRequest {}
_ bin .Decoder = &MessagesTogglePeerTranslationsRequest {}
_ bin .BareEncoder = &MessagesTogglePeerTranslationsRequest {}
_ bin .BareDecoder = &MessagesTogglePeerTranslationsRequest {}
)
func (t *MessagesTogglePeerTranslationsRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .Disabled == false ) {
return false
}
if !(t .Peer == nil ) {
return false
}
return true
}
func (t *MessagesTogglePeerTranslationsRequest ) String () string {
if t == nil {
return "MessagesTogglePeerTranslationsRequest(nil)"
}
type Alias MessagesTogglePeerTranslationsRequest
return fmt .Sprintf ("MessagesTogglePeerTranslationsRequest%+v" , Alias (*t ))
}
func (t *MessagesTogglePeerTranslationsRequest ) FillFrom (from interface {
GetDisabled () (value bool )
GetPeer () (value InputPeerClass )
}) {
t .Disabled = from .GetDisabled ()
t .Peer = from .GetPeer ()
}
func (*MessagesTogglePeerTranslationsRequest ) TypeID () uint32 {
return MessagesTogglePeerTranslationsRequestTypeID
}
func (*MessagesTogglePeerTranslationsRequest ) TypeName () string {
return "messages.togglePeerTranslations"
}
func (t *MessagesTogglePeerTranslationsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.togglePeerTranslations" ,
ID : MessagesTogglePeerTranslationsRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Disabled" ,
SchemaName : "disabled" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
}
return typ
}
func (t *MessagesTogglePeerTranslationsRequest ) SetFlags () {
if !(t .Disabled == false ) {
t .Flags .Set (0 )
}
}
func (t *MessagesTogglePeerTranslationsRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.togglePeerTranslations#e47cb579 as nil" )
}
b .PutID (MessagesTogglePeerTranslationsRequestTypeID )
return t .EncodeBare (b )
}
func (t *MessagesTogglePeerTranslationsRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.togglePeerTranslations#e47cb579 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.togglePeerTranslations#e47cb579: field flags: %w" , err )
}
if t .Peer == nil {
return fmt .Errorf ("unable to encode messages.togglePeerTranslations#e47cb579: field peer is nil" )
}
if err := t .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.togglePeerTranslations#e47cb579: field peer: %w" , err )
}
return nil
}
func (t *MessagesTogglePeerTranslationsRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.togglePeerTranslations#e47cb579 to nil" )
}
if err := b .ConsumeID (MessagesTogglePeerTranslationsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.togglePeerTranslations#e47cb579: %w" , err )
}
return t .DecodeBare (b )
}
func (t *MessagesTogglePeerTranslationsRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.togglePeerTranslations#e47cb579 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.togglePeerTranslations#e47cb579: field flags: %w" , err )
}
}
t .Disabled = t .Flags .Has (0 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.togglePeerTranslations#e47cb579: field peer: %w" , err )
}
t .Peer = value
}
return nil
}
func (t *MessagesTogglePeerTranslationsRequest ) SetDisabled (value bool ) {
if value {
t .Flags .Set (0 )
t .Disabled = true
} else {
t .Flags .Unset (0 )
t .Disabled = false
}
}
func (t *MessagesTogglePeerTranslationsRequest ) GetDisabled () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (0 )
}
func (t *MessagesTogglePeerTranslationsRequest ) GetPeer () (value InputPeerClass ) {
if t == nil {
return
}
return t .Peer
}
func (c *Client ) MessagesTogglePeerTranslations (ctx context .Context , request *MessagesTogglePeerTranslationsRequest ) (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 .