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 MessagesDeleteMessagesRequest struct {
Flags bin .Fields
Revoke bool
ID []int
}
const MessagesDeleteMessagesRequestTypeID = 0xe58e95d2
var (
_ bin .Encoder = &MessagesDeleteMessagesRequest {}
_ bin .Decoder = &MessagesDeleteMessagesRequest {}
_ bin .BareEncoder = &MessagesDeleteMessagesRequest {}
_ bin .BareDecoder = &MessagesDeleteMessagesRequest {}
)
func (d *MessagesDeleteMessagesRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Revoke == false ) {
return false
}
if !(d .ID == nil ) {
return false
}
return true
}
func (d *MessagesDeleteMessagesRequest ) String () string {
if d == nil {
return "MessagesDeleteMessagesRequest(nil)"
}
type Alias MessagesDeleteMessagesRequest
return fmt .Sprintf ("MessagesDeleteMessagesRequest%+v" , Alias (*d ))
}
func (d *MessagesDeleteMessagesRequest ) FillFrom (from interface {
GetRevoke () (value bool )
GetID () (value []int )
}) {
d .Revoke = from .GetRevoke ()
d .ID = from .GetID ()
}
func (*MessagesDeleteMessagesRequest ) TypeID () uint32 {
return MessagesDeleteMessagesRequestTypeID
}
func (*MessagesDeleteMessagesRequest ) TypeName () string {
return "messages.deleteMessages"
}
func (d *MessagesDeleteMessagesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.deleteMessages" ,
ID : MessagesDeleteMessagesRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Revoke" ,
SchemaName : "revoke" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (d *MessagesDeleteMessagesRequest ) SetFlags () {
if !(d .Revoke == false ) {
d .Flags .Set (0 )
}
}
func (d *MessagesDeleteMessagesRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.deleteMessages#e58e95d2 as nil" )
}
b .PutID (MessagesDeleteMessagesRequestTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDeleteMessagesRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.deleteMessages#e58e95d2 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.deleteMessages#e58e95d2: field flags: %w" , err )
}
b .PutVectorHeader (len (d .ID ))
for _ , v := range d .ID {
b .PutInt (v )
}
return nil
}
func (d *MessagesDeleteMessagesRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.deleteMessages#e58e95d2 to nil" )
}
if err := b .ConsumeID (MessagesDeleteMessagesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.deleteMessages#e58e95d2: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDeleteMessagesRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.deleteMessages#e58e95d2 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.deleteMessages#e58e95d2: field flags: %w" , err )
}
}
d .Revoke = d .Flags .Has (0 )
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteMessages#e58e95d2: field id: %w" , err )
}
if headerLen > 0 {
d .ID = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteMessages#e58e95d2: field id: %w" , err )
}
d .ID = append (d .ID , value )
}
}
return nil
}
func (d *MessagesDeleteMessagesRequest ) SetRevoke (value bool ) {
if value {
d .Flags .Set (0 )
d .Revoke = true
} else {
d .Flags .Unset (0 )
d .Revoke = false
}
}
func (d *MessagesDeleteMessagesRequest ) GetRevoke () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *MessagesDeleteMessagesRequest ) GetID () (value []int ) {
if d == nil {
return
}
return d .ID
}
func (c *Client ) MessagesDeleteMessages (ctx context .Context , request *MessagesDeleteMessagesRequest ) (*MessagesAffectedMessages , error ) {
var result MessagesAffectedMessages
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .