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 MessagesGetSearchCountersRequest struct {
Flags bin .Fields
Peer InputPeerClass
TopMsgID int
Filters []MessagesFilterClass
}
const MessagesGetSearchCountersRequestTypeID = 0xae7cc1
var (
_ bin .Encoder = &MessagesGetSearchCountersRequest {}
_ bin .Decoder = &MessagesGetSearchCountersRequest {}
_ bin .BareEncoder = &MessagesGetSearchCountersRequest {}
_ bin .BareDecoder = &MessagesGetSearchCountersRequest {}
)
func (g *MessagesGetSearchCountersRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Peer == nil ) {
return false
}
if !(g .TopMsgID == 0 ) {
return false
}
if !(g .Filters == nil ) {
return false
}
return true
}
func (g *MessagesGetSearchCountersRequest ) String () string {
if g == nil {
return "MessagesGetSearchCountersRequest(nil)"
}
type Alias MessagesGetSearchCountersRequest
return fmt .Sprintf ("MessagesGetSearchCountersRequest%+v" , Alias (*g ))
}
func (g *MessagesGetSearchCountersRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetTopMsgID () (value int , ok bool )
GetFilters () (value []MessagesFilterClass )
}) {
g .Peer = from .GetPeer ()
if val , ok := from .GetTopMsgID (); ok {
g .TopMsgID = val
}
g .Filters = from .GetFilters ()
}
func (*MessagesGetSearchCountersRequest ) TypeID () uint32 {
return MessagesGetSearchCountersRequestTypeID
}
func (*MessagesGetSearchCountersRequest ) TypeName () string {
return "messages.getSearchCounters"
}
func (g *MessagesGetSearchCountersRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getSearchCounters" ,
ID : MessagesGetSearchCountersRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "TopMsgID" ,
SchemaName : "top_msg_id" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "Filters" ,
SchemaName : "filters" ,
},
}
return typ
}
func (g *MessagesGetSearchCountersRequest ) SetFlags () {
if !(g .TopMsgID == 0 ) {
g .Flags .Set (0 )
}
}
func (g *MessagesGetSearchCountersRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getSearchCounters#ae7cc1 as nil" )
}
b .PutID (MessagesGetSearchCountersRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetSearchCountersRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getSearchCounters#ae7cc1 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getSearchCounters#ae7cc1: field flags: %w" , err )
}
if g .Peer == nil {
return fmt .Errorf ("unable to encode messages.getSearchCounters#ae7cc1: field peer is nil" )
}
if err := g .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getSearchCounters#ae7cc1: field peer: %w" , err )
}
if g .Flags .Has (0 ) {
b .PutInt (g .TopMsgID )
}
b .PutVectorHeader (len (g .Filters ))
for idx , v := range g .Filters {
if v == nil {
return fmt .Errorf ("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d: %w" , idx , err )
}
}
return nil
}
func (g *MessagesGetSearchCountersRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getSearchCounters#ae7cc1 to nil" )
}
if err := b .ConsumeID (MessagesGetSearchCountersRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetSearchCountersRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getSearchCounters#ae7cc1 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: field flags: %w" , err )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: field peer: %w" , err )
}
g .Peer = value
}
if g .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: field top_msg_id: %w" , err )
}
g .TopMsgID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: field filters: %w" , err )
}
if headerLen > 0 {
g .Filters = make ([]MessagesFilterClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessagesFilter (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getSearchCounters#ae7cc1: field filters: %w" , err )
}
g .Filters = append (g .Filters , value )
}
}
return nil
}
func (g *MessagesGetSearchCountersRequest ) GetPeer () (value InputPeerClass ) {
if g == nil {
return
}
return g .Peer
}
func (g *MessagesGetSearchCountersRequest ) SetTopMsgID (value int ) {
g .Flags .Set (0 )
g .TopMsgID = value
}
func (g *MessagesGetSearchCountersRequest ) GetTopMsgID () (value int , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .TopMsgID , true
}
func (g *MessagesGetSearchCountersRequest ) GetFilters () (value []MessagesFilterClass ) {
if g == nil {
return
}
return g .Filters
}
func (g *MessagesGetSearchCountersRequest ) MapFilters () (value MessagesFilterClassArray ) {
return MessagesFilterClassArray (g .Filters )
}
func (c *Client ) MessagesGetSearchCounters (ctx context .Context , request *MessagesGetSearchCountersRequest ) ([]MessagesSearchCounter , error ) {
var result MessagesSearchCounterVector
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []MessagesSearchCounter (result .Elems ), 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 .