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 StoriesSearchPostsRequest struct {
Flags bin .Fields
Hashtag string
Area MediaAreaClass
Peer InputPeerClass
Offset string
Limit int
}
const StoriesSearchPostsRequestTypeID = 0xd1810907
var (
_ bin .Encoder = &StoriesSearchPostsRequest {}
_ bin .Decoder = &StoriesSearchPostsRequest {}
_ bin .BareEncoder = &StoriesSearchPostsRequest {}
_ bin .BareDecoder = &StoriesSearchPostsRequest {}
)
func (s *StoriesSearchPostsRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Hashtag == "" ) {
return false
}
if !(s .Area == nil ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .Offset == "" ) {
return false
}
if !(s .Limit == 0 ) {
return false
}
return true
}
func (s *StoriesSearchPostsRequest ) String () string {
if s == nil {
return "StoriesSearchPostsRequest(nil)"
}
type Alias StoriesSearchPostsRequest
return fmt .Sprintf ("StoriesSearchPostsRequest%+v" , Alias (*s ))
}
func (s *StoriesSearchPostsRequest ) FillFrom (from interface {
GetHashtag () (value string , ok bool )
GetArea () (value MediaAreaClass , ok bool )
GetPeer () (value InputPeerClass , ok bool )
GetOffset () (value string )
GetLimit () (value int )
}) {
if val , ok := from .GetHashtag (); ok {
s .Hashtag = val
}
if val , ok := from .GetArea (); ok {
s .Area = val
}
if val , ok := from .GetPeer (); ok {
s .Peer = val
}
s .Offset = from .GetOffset ()
s .Limit = from .GetLimit ()
}
func (*StoriesSearchPostsRequest ) TypeID () uint32 {
return StoriesSearchPostsRequestTypeID
}
func (*StoriesSearchPostsRequest ) TypeName () string {
return "stories.searchPosts"
}
func (s *StoriesSearchPostsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.searchPosts" ,
ID : StoriesSearchPostsRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hashtag" ,
SchemaName : "hashtag" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Area" ,
SchemaName : "area" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Offset" ,
SchemaName : "offset" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (s *StoriesSearchPostsRequest ) SetFlags () {
if !(s .Hashtag == "" ) {
s .Flags .Set (0 )
}
if !(s .Area == nil ) {
s .Flags .Set (1 )
}
if !(s .Peer == nil ) {
s .Flags .Set (2 )
}
}
func (s *StoriesSearchPostsRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.searchPosts#d1810907 as nil" )
}
b .PutID (StoriesSearchPostsRequestTypeID )
return s .EncodeBare (b )
}
func (s *StoriesSearchPostsRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.searchPosts#d1810907 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.searchPosts#d1810907: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutString (s .Hashtag )
}
if s .Flags .Has (1 ) {
if s .Area == nil {
return fmt .Errorf ("unable to encode stories.searchPosts#d1810907: field area is nil" )
}
if err := s .Area .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.searchPosts#d1810907: field area: %w" , err )
}
}
if s .Flags .Has (2 ) {
if s .Peer == nil {
return fmt .Errorf ("unable to encode stories.searchPosts#d1810907: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.searchPosts#d1810907: field peer: %w" , err )
}
}
b .PutString (s .Offset )
b .PutInt (s .Limit )
return nil
}
func (s *StoriesSearchPostsRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.searchPosts#d1810907 to nil" )
}
if err := b .ConsumeID (StoriesSearchPostsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesSearchPostsRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.searchPosts#d1810907 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field flags: %w" , err )
}
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field hashtag: %w" , err )
}
s .Hashtag = value
}
if s .Flags .Has (1 ) {
value , err := DecodeMediaArea (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field area: %w" , err )
}
s .Area = value
}
if s .Flags .Has (2 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field offset: %w" , err )
}
s .Offset = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.searchPosts#d1810907: field limit: %w" , err )
}
s .Limit = value
}
return nil
}
func (s *StoriesSearchPostsRequest ) SetHashtag (value string ) {
s .Flags .Set (0 )
s .Hashtag = value
}
func (s *StoriesSearchPostsRequest ) GetHashtag () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Hashtag , true
}
func (s *StoriesSearchPostsRequest ) SetArea (value MediaAreaClass ) {
s .Flags .Set (1 )
s .Area = value
}
func (s *StoriesSearchPostsRequest ) GetArea () (value MediaAreaClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Area , true
}
func (s *StoriesSearchPostsRequest ) SetPeer (value InputPeerClass ) {
s .Flags .Set (2 )
s .Peer = value
}
func (s *StoriesSearchPostsRequest ) GetPeer () (value InputPeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .Peer , true
}
func (s *StoriesSearchPostsRequest ) GetOffset () (value string ) {
if s == nil {
return
}
return s .Offset
}
func (s *StoriesSearchPostsRequest ) GetLimit () (value int ) {
if s == nil {
return
}
return s .Limit
}
func (c *Client ) StoriesSearchPosts (ctx context .Context , request *StoriesSearchPostsRequest ) (*StoriesFoundStories , error ) {
var result StoriesFoundStories
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , nil
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .