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 MessagesDiscardEncryptionRequest struct {
Flags bin .Fields
DeleteHistory bool
ChatID int
}
const MessagesDiscardEncryptionRequestTypeID = 0xf393aea0
var (
_ bin .Encoder = &MessagesDiscardEncryptionRequest {}
_ bin .Decoder = &MessagesDiscardEncryptionRequest {}
_ bin .BareEncoder = &MessagesDiscardEncryptionRequest {}
_ bin .BareDecoder = &MessagesDiscardEncryptionRequest {}
)
func (d *MessagesDiscardEncryptionRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .DeleteHistory == false ) {
return false
}
if !(d .ChatID == 0 ) {
return false
}
return true
}
func (d *MessagesDiscardEncryptionRequest ) String () string {
if d == nil {
return "MessagesDiscardEncryptionRequest(nil)"
}
type Alias MessagesDiscardEncryptionRequest
return fmt .Sprintf ("MessagesDiscardEncryptionRequest%+v" , Alias (*d ))
}
func (d *MessagesDiscardEncryptionRequest ) FillFrom (from interface {
GetDeleteHistory () (value bool )
GetChatID () (value int )
}) {
d .DeleteHistory = from .GetDeleteHistory ()
d .ChatID = from .GetChatID ()
}
func (*MessagesDiscardEncryptionRequest ) TypeID () uint32 {
return MessagesDiscardEncryptionRequestTypeID
}
func (*MessagesDiscardEncryptionRequest ) TypeName () string {
return "messages.discardEncryption"
}
func (d *MessagesDiscardEncryptionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.discardEncryption" ,
ID : MessagesDiscardEncryptionRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "DeleteHistory" ,
SchemaName : "delete_history" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
}
return typ
}
func (d *MessagesDiscardEncryptionRequest ) SetFlags () {
if !(d .DeleteHistory == false ) {
d .Flags .Set (0 )
}
}
func (d *MessagesDiscardEncryptionRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.discardEncryption#f393aea0 as nil" )
}
b .PutID (MessagesDiscardEncryptionRequestTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDiscardEncryptionRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.discardEncryption#f393aea0 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.discardEncryption#f393aea0: field flags: %w" , err )
}
b .PutInt (d .ChatID )
return nil
}
func (d *MessagesDiscardEncryptionRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.discardEncryption#f393aea0 to nil" )
}
if err := b .ConsumeID (MessagesDiscardEncryptionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.discardEncryption#f393aea0: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDiscardEncryptionRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.discardEncryption#f393aea0 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.discardEncryption#f393aea0: field flags: %w" , err )
}
}
d .DeleteHistory = d .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discardEncryption#f393aea0: field chat_id: %w" , err )
}
d .ChatID = value
}
return nil
}
func (d *MessagesDiscardEncryptionRequest ) SetDeleteHistory (value bool ) {
if value {
d .Flags .Set (0 )
d .DeleteHistory = true
} else {
d .Flags .Unset (0 )
d .DeleteHistory = false
}
}
func (d *MessagesDiscardEncryptionRequest ) GetDeleteHistory () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *MessagesDiscardEncryptionRequest ) GetChatID () (value int ) {
if d == nil {
return
}
return d .ChatID
}
func (c *Client ) MessagesDiscardEncryption (ctx context .Context , request *MessagesDiscardEncryptionRequest ) (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 .