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 MessagesSearchGlobalRequest struct {
Flags bin .Fields
FolderID int
Q string
Filter MessagesFilterClass
MinDate int
MaxDate int
OffsetRate int
OffsetPeer InputPeerClass
OffsetID int
Limit int
}
const MessagesSearchGlobalRequestTypeID = 0x4bc6589a
var (
_ bin .Encoder = &MessagesSearchGlobalRequest {}
_ bin .Decoder = &MessagesSearchGlobalRequest {}
_ bin .BareEncoder = &MessagesSearchGlobalRequest {}
_ bin .BareDecoder = &MessagesSearchGlobalRequest {}
)
func (s *MessagesSearchGlobalRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .FolderID == 0 ) {
return false
}
if !(s .Q == "" ) {
return false
}
if !(s .Filter == nil ) {
return false
}
if !(s .MinDate == 0 ) {
return false
}
if !(s .MaxDate == 0 ) {
return false
}
if !(s .OffsetRate == 0 ) {
return false
}
if !(s .OffsetPeer == nil ) {
return false
}
if !(s .OffsetID == 0 ) {
return false
}
if !(s .Limit == 0 ) {
return false
}
return true
}
func (s *MessagesSearchGlobalRequest ) String () string {
if s == nil {
return "MessagesSearchGlobalRequest(nil)"
}
type Alias MessagesSearchGlobalRequest
return fmt .Sprintf ("MessagesSearchGlobalRequest%+v" , Alias (*s ))
}
func (s *MessagesSearchGlobalRequest ) FillFrom (from interface {
GetFolderID () (value int , ok bool )
GetQ () (value string )
GetFilter () (value MessagesFilterClass )
GetMinDate () (value int )
GetMaxDate () (value int )
GetOffsetRate () (value int )
GetOffsetPeer () (value InputPeerClass )
GetOffsetID () (value int )
GetLimit () (value int )
}) {
if val , ok := from .GetFolderID (); ok {
s .FolderID = val
}
s .Q = from .GetQ ()
s .Filter = from .GetFilter ()
s .MinDate = from .GetMinDate ()
s .MaxDate = from .GetMaxDate ()
s .OffsetRate = from .GetOffsetRate ()
s .OffsetPeer = from .GetOffsetPeer ()
s .OffsetID = from .GetOffsetID ()
s .Limit = from .GetLimit ()
}
func (*MessagesSearchGlobalRequest ) TypeID () uint32 {
return MessagesSearchGlobalRequestTypeID
}
func (*MessagesSearchGlobalRequest ) TypeName () string {
return "messages.searchGlobal"
}
func (s *MessagesSearchGlobalRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.searchGlobal" ,
ID : MessagesSearchGlobalRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "FolderID" ,
SchemaName : "folder_id" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Q" ,
SchemaName : "q" ,
},
{
Name : "Filter" ,
SchemaName : "filter" ,
},
{
Name : "MinDate" ,
SchemaName : "min_date" ,
},
{
Name : "MaxDate" ,
SchemaName : "max_date" ,
},
{
Name : "OffsetRate" ,
SchemaName : "offset_rate" ,
},
{
Name : "OffsetPeer" ,
SchemaName : "offset_peer" ,
},
{
Name : "OffsetID" ,
SchemaName : "offset_id" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (s *MessagesSearchGlobalRequest ) SetFlags () {
if !(s .FolderID == 0 ) {
s .Flags .Set (0 )
}
}
func (s *MessagesSearchGlobalRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchGlobal#4bc6589a as nil" )
}
b .PutID (MessagesSearchGlobalRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSearchGlobalRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchGlobal#4bc6589a as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchGlobal#4bc6589a: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutInt (s .FolderID )
}
b .PutString (s .Q )
if s .Filter == nil {
return fmt .Errorf ("unable to encode messages.searchGlobal#4bc6589a: field filter is nil" )
}
if err := s .Filter .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchGlobal#4bc6589a: field filter: %w" , err )
}
b .PutInt (s .MinDate )
b .PutInt (s .MaxDate )
b .PutInt (s .OffsetRate )
if s .OffsetPeer == nil {
return fmt .Errorf ("unable to encode messages.searchGlobal#4bc6589a: field offset_peer is nil" )
}
if err := s .OffsetPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchGlobal#4bc6589a: field offset_peer: %w" , err )
}
b .PutInt (s .OffsetID )
b .PutInt (s .Limit )
return nil
}
func (s *MessagesSearchGlobalRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchGlobal#4bc6589a to nil" )
}
if err := b .ConsumeID (MessagesSearchGlobalRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSearchGlobalRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchGlobal#4bc6589a to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field flags: %w" , err )
}
}
if s .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field folder_id: %w" , err )
}
s .FolderID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field q: %w" , err )
}
s .Q = value
}
{
value , err := DecodeMessagesFilter (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field filter: %w" , err )
}
s .Filter = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field min_date: %w" , err )
}
s .MinDate = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field max_date: %w" , err )
}
s .MaxDate = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field offset_rate: %w" , err )
}
s .OffsetRate = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field offset_peer: %w" , err )
}
s .OffsetPeer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field offset_id: %w" , err )
}
s .OffsetID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchGlobal#4bc6589a: field limit: %w" , err )
}
s .Limit = value
}
return nil
}
func (s *MessagesSearchGlobalRequest ) SetFolderID (value int ) {
s .Flags .Set (0 )
s .FolderID = value
}
func (s *MessagesSearchGlobalRequest ) GetFolderID () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .FolderID , true
}
func (s *MessagesSearchGlobalRequest ) GetQ () (value string ) {
if s == nil {
return
}
return s .Q
}
func (s *MessagesSearchGlobalRequest ) GetFilter () (value MessagesFilterClass ) {
if s == nil {
return
}
return s .Filter
}
func (s *MessagesSearchGlobalRequest ) GetMinDate () (value int ) {
if s == nil {
return
}
return s .MinDate
}
func (s *MessagesSearchGlobalRequest ) GetMaxDate () (value int ) {
if s == nil {
return
}
return s .MaxDate
}
func (s *MessagesSearchGlobalRequest ) GetOffsetRate () (value int ) {
if s == nil {
return
}
return s .OffsetRate
}
func (s *MessagesSearchGlobalRequest ) GetOffsetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .OffsetPeer
}
func (s *MessagesSearchGlobalRequest ) GetOffsetID () (value int ) {
if s == nil {
return
}
return s .OffsetID
}
func (s *MessagesSearchGlobalRequest ) GetLimit () (value int ) {
if s == nil {
return
}
return s .Limit
}
func (c *Client ) MessagesSearchGlobal (ctx context .Context , request *MessagesSearchGlobalRequest ) (MessagesMessagesClass , error ) {
var result MessagesMessagesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Messages , 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 .