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 ChannelsDeleteMessagesRequest struct {
Channel InputChannelClass
ID []int
}
const ChannelsDeleteMessagesRequestTypeID = 0x84c1fd4e
var (
_ bin .Encoder = &ChannelsDeleteMessagesRequest {}
_ bin .Decoder = &ChannelsDeleteMessagesRequest {}
_ bin .BareEncoder = &ChannelsDeleteMessagesRequest {}
_ bin .BareDecoder = &ChannelsDeleteMessagesRequest {}
)
func (d *ChannelsDeleteMessagesRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Channel == nil ) {
return false
}
if !(d .ID == nil ) {
return false
}
return true
}
func (d *ChannelsDeleteMessagesRequest ) String () string {
if d == nil {
return "ChannelsDeleteMessagesRequest(nil)"
}
type Alias ChannelsDeleteMessagesRequest
return fmt .Sprintf ("ChannelsDeleteMessagesRequest%+v" , Alias (*d ))
}
func (d *ChannelsDeleteMessagesRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetID () (value []int )
}) {
d .Channel = from .GetChannel ()
d .ID = from .GetID ()
}
func (*ChannelsDeleteMessagesRequest ) TypeID () uint32 {
return ChannelsDeleteMessagesRequestTypeID
}
func (*ChannelsDeleteMessagesRequest ) TypeName () string {
return "channels.deleteMessages"
}
func (d *ChannelsDeleteMessagesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.deleteMessages" ,
ID : ChannelsDeleteMessagesRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (d *ChannelsDeleteMessagesRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode channels.deleteMessages#84c1fd4e as nil" )
}
b .PutID (ChannelsDeleteMessagesRequestTypeID )
return d .EncodeBare (b )
}
func (d *ChannelsDeleteMessagesRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode channels.deleteMessages#84c1fd4e as nil" )
}
if d .Channel == nil {
return fmt .Errorf ("unable to encode channels.deleteMessages#84c1fd4e: field channel is nil" )
}
if err := d .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.deleteMessages#84c1fd4e: field channel: %w" , err )
}
b .PutVectorHeader (len (d .ID ))
for _ , v := range d .ID {
b .PutInt (v )
}
return nil
}
func (d *ChannelsDeleteMessagesRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode channels.deleteMessages#84c1fd4e to nil" )
}
if err := b .ConsumeID (ChannelsDeleteMessagesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.deleteMessages#84c1fd4e: %w" , err )
}
return d .DecodeBare (b )
}
func (d *ChannelsDeleteMessagesRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode channels.deleteMessages#84c1fd4e to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.deleteMessages#84c1fd4e: field channel: %w" , err )
}
d .Channel = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.deleteMessages#84c1fd4e: 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 channels.deleteMessages#84c1fd4e: field id: %w" , err )
}
d .ID = append (d .ID , value )
}
}
return nil
}
func (d *ChannelsDeleteMessagesRequest ) GetChannel () (value InputChannelClass ) {
if d == nil {
return
}
return d .Channel
}
func (d *ChannelsDeleteMessagesRequest ) GetID () (value []int ) {
if d == nil {
return
}
return d .ID
}
func (d *ChannelsDeleteMessagesRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return d .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsDeleteMessages (ctx context .Context , request *ChannelsDeleteMessagesRequest ) (*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 .