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 MessagesDeleteHistoryRequest struct {
Flags bin .Fields
JustClear bool
Revoke bool
Peer InputPeerClass
MaxID int
MinDate int
MaxDate int
}
const MessagesDeleteHistoryRequestTypeID = 0xb08f922a
var (
_ bin .Encoder = &MessagesDeleteHistoryRequest {}
_ bin .Decoder = &MessagesDeleteHistoryRequest {}
_ bin .BareEncoder = &MessagesDeleteHistoryRequest {}
_ bin .BareDecoder = &MessagesDeleteHistoryRequest {}
)
func (d *MessagesDeleteHistoryRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .JustClear == false ) {
return false
}
if !(d .Revoke == false ) {
return false
}
if !(d .Peer == nil ) {
return false
}
if !(d .MaxID == 0 ) {
return false
}
if !(d .MinDate == 0 ) {
return false
}
if !(d .MaxDate == 0 ) {
return false
}
return true
}
func (d *MessagesDeleteHistoryRequest ) String () string {
if d == nil {
return "MessagesDeleteHistoryRequest(nil)"
}
type Alias MessagesDeleteHistoryRequest
return fmt .Sprintf ("MessagesDeleteHistoryRequest%+v" , Alias (*d ))
}
func (d *MessagesDeleteHistoryRequest ) FillFrom (from interface {
GetJustClear () (value bool )
GetRevoke () (value bool )
GetPeer () (value InputPeerClass )
GetMaxID () (value int )
GetMinDate () (value int , ok bool )
GetMaxDate () (value int , ok bool )
}) {
d .JustClear = from .GetJustClear ()
d .Revoke = from .GetRevoke ()
d .Peer = from .GetPeer ()
d .MaxID = from .GetMaxID ()
if val , ok := from .GetMinDate (); ok {
d .MinDate = val
}
if val , ok := from .GetMaxDate (); ok {
d .MaxDate = val
}
}
func (*MessagesDeleteHistoryRequest ) TypeID () uint32 {
return MessagesDeleteHistoryRequestTypeID
}
func (*MessagesDeleteHistoryRequest ) TypeName () string {
return "messages.deleteHistory"
}
func (d *MessagesDeleteHistoryRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.deleteHistory" ,
ID : MessagesDeleteHistoryRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "JustClear" ,
SchemaName : "just_clear" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "Revoke" ,
SchemaName : "revoke" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MaxID" ,
SchemaName : "max_id" ,
},
{
Name : "MinDate" ,
SchemaName : "min_date" ,
Null : !d .Flags .Has (2 ),
},
{
Name : "MaxDate" ,
SchemaName : "max_date" ,
Null : !d .Flags .Has (3 ),
},
}
return typ
}
func (d *MessagesDeleteHistoryRequest ) SetFlags () {
if !(d .JustClear == false ) {
d .Flags .Set (0 )
}
if !(d .Revoke == false ) {
d .Flags .Set (1 )
}
if !(d .MinDate == 0 ) {
d .Flags .Set (2 )
}
if !(d .MaxDate == 0 ) {
d .Flags .Set (3 )
}
}
func (d *MessagesDeleteHistoryRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.deleteHistory#b08f922a as nil" )
}
b .PutID (MessagesDeleteHistoryRequestTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDeleteHistoryRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.deleteHistory#b08f922a as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.deleteHistory#b08f922a: field flags: %w" , err )
}
if d .Peer == nil {
return fmt .Errorf ("unable to encode messages.deleteHistory#b08f922a: field peer is nil" )
}
if err := d .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.deleteHistory#b08f922a: field peer: %w" , err )
}
b .PutInt (d .MaxID )
if d .Flags .Has (2 ) {
b .PutInt (d .MinDate )
}
if d .Flags .Has (3 ) {
b .PutInt (d .MaxDate )
}
return nil
}
func (d *MessagesDeleteHistoryRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.deleteHistory#b08f922a to nil" )
}
if err := b .ConsumeID (MessagesDeleteHistoryRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDeleteHistoryRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.deleteHistory#b08f922a to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: field flags: %w" , err )
}
}
d .JustClear = d .Flags .Has (0 )
d .Revoke = d .Flags .Has (1 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: field peer: %w" , err )
}
d .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: field max_id: %w" , err )
}
d .MaxID = value
}
if d .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: field min_date: %w" , err )
}
d .MinDate = value
}
if d .Flags .Has (3 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.deleteHistory#b08f922a: field max_date: %w" , err )
}
d .MaxDate = value
}
return nil
}
func (d *MessagesDeleteHistoryRequest ) SetJustClear (value bool ) {
if value {
d .Flags .Set (0 )
d .JustClear = true
} else {
d .Flags .Unset (0 )
d .JustClear = false
}
}
func (d *MessagesDeleteHistoryRequest ) GetJustClear () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *MessagesDeleteHistoryRequest ) SetRevoke (value bool ) {
if value {
d .Flags .Set (1 )
d .Revoke = true
} else {
d .Flags .Unset (1 )
d .Revoke = false
}
}
func (d *MessagesDeleteHistoryRequest ) GetRevoke () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (1 )
}
func (d *MessagesDeleteHistoryRequest ) GetPeer () (value InputPeerClass ) {
if d == nil {
return
}
return d .Peer
}
func (d *MessagesDeleteHistoryRequest ) GetMaxID () (value int ) {
if d == nil {
return
}
return d .MaxID
}
func (d *MessagesDeleteHistoryRequest ) SetMinDate (value int ) {
d .Flags .Set (2 )
d .MinDate = value
}
func (d *MessagesDeleteHistoryRequest ) GetMinDate () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (2 ) {
return value , false
}
return d .MinDate , true
}
func (d *MessagesDeleteHistoryRequest ) SetMaxDate (value int ) {
d .Flags .Set (3 )
d .MaxDate = value
}
func (d *MessagesDeleteHistoryRequest ) GetMaxDate () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (3 ) {
return value , false
}
return d .MaxDate , true
}
func (c *Client ) MessagesDeleteHistory (ctx context .Context , request *MessagesDeleteHistoryRequest ) (*MessagesAffectedHistory , error ) {
var result MessagesAffectedHistory
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 .