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 MessagesUnpinAllMessagesRequest struct {
Flags bin .Fields
Peer InputPeerClass
TopMsgID int
}
const MessagesUnpinAllMessagesRequestTypeID = 0xee22b9a8
var (
_ bin .Encoder = &MessagesUnpinAllMessagesRequest {}
_ bin .Decoder = &MessagesUnpinAllMessagesRequest {}
_ bin .BareEncoder = &MessagesUnpinAllMessagesRequest {}
_ bin .BareDecoder = &MessagesUnpinAllMessagesRequest {}
)
func (u *MessagesUnpinAllMessagesRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Peer == nil ) {
return false
}
if !(u .TopMsgID == 0 ) {
return false
}
return true
}
func (u *MessagesUnpinAllMessagesRequest ) String () string {
if u == nil {
return "MessagesUnpinAllMessagesRequest(nil)"
}
type Alias MessagesUnpinAllMessagesRequest
return fmt .Sprintf ("MessagesUnpinAllMessagesRequest%+v" , Alias (*u ))
}
func (u *MessagesUnpinAllMessagesRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetTopMsgID () (value int , ok bool )
}) {
u .Peer = from .GetPeer ()
if val , ok := from .GetTopMsgID (); ok {
u .TopMsgID = val
}
}
func (*MessagesUnpinAllMessagesRequest ) TypeID () uint32 {
return MessagesUnpinAllMessagesRequestTypeID
}
func (*MessagesUnpinAllMessagesRequest ) TypeName () string {
return "messages.unpinAllMessages"
}
func (u *MessagesUnpinAllMessagesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.unpinAllMessages" ,
ID : MessagesUnpinAllMessagesRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "TopMsgID" ,
SchemaName : "top_msg_id" ,
Null : !u .Flags .Has (0 ),
},
}
return typ
}
func (u *MessagesUnpinAllMessagesRequest ) SetFlags () {
if !(u .TopMsgID == 0 ) {
u .Flags .Set (0 )
}
}
func (u *MessagesUnpinAllMessagesRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode messages.unpinAllMessages#ee22b9a8 as nil" )
}
b .PutID (MessagesUnpinAllMessagesRequestTypeID )
return u .EncodeBare (b )
}
func (u *MessagesUnpinAllMessagesRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode messages.unpinAllMessages#ee22b9a8 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.unpinAllMessages#ee22b9a8: field flags: %w" , err )
}
if u .Peer == nil {
return fmt .Errorf ("unable to encode messages.unpinAllMessages#ee22b9a8: field peer is nil" )
}
if err := u .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.unpinAllMessages#ee22b9a8: field peer: %w" , err )
}
if u .Flags .Has (0 ) {
b .PutInt (u .TopMsgID )
}
return nil
}
func (u *MessagesUnpinAllMessagesRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode messages.unpinAllMessages#ee22b9a8 to nil" )
}
if err := b .ConsumeID (MessagesUnpinAllMessagesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.unpinAllMessages#ee22b9a8: %w" , err )
}
return u .DecodeBare (b )
}
func (u *MessagesUnpinAllMessagesRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode messages.unpinAllMessages#ee22b9a8 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.unpinAllMessages#ee22b9a8: field flags: %w" , err )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.unpinAllMessages#ee22b9a8: field peer: %w" , err )
}
u .Peer = value
}
if u .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.unpinAllMessages#ee22b9a8: field top_msg_id: %w" , err )
}
u .TopMsgID = value
}
return nil
}
func (u *MessagesUnpinAllMessagesRequest ) GetPeer () (value InputPeerClass ) {
if u == nil {
return
}
return u .Peer
}
func (u *MessagesUnpinAllMessagesRequest ) SetTopMsgID (value int ) {
u .Flags .Set (0 )
u .TopMsgID = value
}
func (u *MessagesUnpinAllMessagesRequest ) GetTopMsgID () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .TopMsgID , true
}
func (c *Client ) MessagesUnpinAllMessages (ctx context .Context , request *MessagesUnpinAllMessagesRequest ) (*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 .