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 MessagesSearchResultsCalendar struct {
Flags bin .Fields
Inexact bool
Count int
MinDate int
MinMsgID int
OffsetIDOffset int
Periods []SearchResultsCalendarPeriod
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const MessagesSearchResultsCalendarTypeID = 0x147ee23c
var (
_ bin .Encoder = &MessagesSearchResultsCalendar {}
_ bin .Decoder = &MessagesSearchResultsCalendar {}
_ bin .BareEncoder = &MessagesSearchResultsCalendar {}
_ bin .BareDecoder = &MessagesSearchResultsCalendar {}
)
func (s *MessagesSearchResultsCalendar ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Inexact == false ) {
return false
}
if !(s .Count == 0 ) {
return false
}
if !(s .MinDate == 0 ) {
return false
}
if !(s .MinMsgID == 0 ) {
return false
}
if !(s .OffsetIDOffset == 0 ) {
return false
}
if !(s .Periods == nil ) {
return false
}
if !(s .Messages == nil ) {
return false
}
if !(s .Chats == nil ) {
return false
}
if !(s .Users == nil ) {
return false
}
return true
}
func (s *MessagesSearchResultsCalendar ) String () string {
if s == nil {
return "MessagesSearchResultsCalendar(nil)"
}
type Alias MessagesSearchResultsCalendar
return fmt .Sprintf ("MessagesSearchResultsCalendar%+v" , Alias (*s ))
}
func (s *MessagesSearchResultsCalendar ) FillFrom (from interface {
GetInexact () (value bool )
GetCount () (value int )
GetMinDate () (value int )
GetMinMsgID () (value int )
GetOffsetIDOffset () (value int , ok bool )
GetPeriods () (value []SearchResultsCalendarPeriod )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
s .Inexact = from .GetInexact ()
s .Count = from .GetCount ()
s .MinDate = from .GetMinDate ()
s .MinMsgID = from .GetMinMsgID ()
if val , ok := from .GetOffsetIDOffset (); ok {
s .OffsetIDOffset = val
}
s .Periods = from .GetPeriods ()
s .Messages = from .GetMessages ()
s .Chats = from .GetChats ()
s .Users = from .GetUsers ()
}
func (*MessagesSearchResultsCalendar ) TypeID () uint32 {
return MessagesSearchResultsCalendarTypeID
}
func (*MessagesSearchResultsCalendar ) TypeName () string {
return "messages.searchResultsCalendar"
}
func (s *MessagesSearchResultsCalendar ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.searchResultsCalendar" ,
ID : MessagesSearchResultsCalendarTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Inexact" ,
SchemaName : "inexact" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "MinDate" ,
SchemaName : "min_date" ,
},
{
Name : "MinMsgID" ,
SchemaName : "min_msg_id" ,
},
{
Name : "OffsetIDOffset" ,
SchemaName : "offset_id_offset" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Periods" ,
SchemaName : "periods" ,
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (s *MessagesSearchResultsCalendar ) SetFlags () {
if !(s .Inexact == false ) {
s .Flags .Set (0 )
}
if !(s .OffsetIDOffset == 0 ) {
s .Flags .Set (1 )
}
}
func (s *MessagesSearchResultsCalendar ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchResultsCalendar#147ee23c as nil" )
}
b .PutID (MessagesSearchResultsCalendarTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSearchResultsCalendar ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchResultsCalendar#147ee23c as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field flags: %w" , err )
}
b .PutInt (s .Count )
b .PutInt (s .MinDate )
b .PutInt (s .MinMsgID )
if s .Flags .Has (1 ) {
b .PutInt (s .OffsetIDOffset )
}
b .PutVectorHeader (len (s .Periods ))
for idx , v := range s .Periods {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field periods element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Messages ))
for idx , v := range s .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Chats ))
for idx , v := range s .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Users ))
for idx , v := range s .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsCalendar#147ee23c: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *MessagesSearchResultsCalendar ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchResultsCalendar#147ee23c to nil" )
}
if err := b .ConsumeID (MessagesSearchResultsCalendarTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSearchResultsCalendar ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchResultsCalendar#147ee23c to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field flags: %w" , err )
}
}
s .Inexact = s .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field count: %w" , err )
}
s .Count = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field min_date: %w" , err )
}
s .MinDate = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field min_msg_id: %w" , err )
}
s .MinMsgID = value
}
if s .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field offset_id_offset: %w" , err )
}
s .OffsetIDOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field periods: %w" , err )
}
if headerLen > 0 {
s .Periods = make ([]SearchResultsCalendarPeriod , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value SearchResultsCalendarPeriod
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field periods: %w" , err )
}
s .Periods = append (s .Periods , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field messages: %w" , err )
}
if headerLen > 0 {
s .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field messages: %w" , err )
}
s .Messages = append (s .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field chats: %w" , err )
}
if headerLen > 0 {
s .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field chats: %w" , err )
}
s .Chats = append (s .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field users: %w" , err )
}
if headerLen > 0 {
s .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsCalendar#147ee23c: field users: %w" , err )
}
s .Users = append (s .Users , value )
}
}
return nil
}
func (s *MessagesSearchResultsCalendar ) SetInexact (value bool ) {
if value {
s .Flags .Set (0 )
s .Inexact = true
} else {
s .Flags .Unset (0 )
s .Inexact = false
}
}
func (s *MessagesSearchResultsCalendar ) GetInexact () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *MessagesSearchResultsCalendar ) GetCount () (value int ) {
if s == nil {
return
}
return s .Count
}
func (s *MessagesSearchResultsCalendar ) GetMinDate () (value int ) {
if s == nil {
return
}
return s .MinDate
}
func (s *MessagesSearchResultsCalendar ) GetMinMsgID () (value int ) {
if s == nil {
return
}
return s .MinMsgID
}
func (s *MessagesSearchResultsCalendar ) SetOffsetIDOffset (value int ) {
s .Flags .Set (1 )
s .OffsetIDOffset = value
}
func (s *MessagesSearchResultsCalendar ) GetOffsetIDOffset () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .OffsetIDOffset , true
}
func (s *MessagesSearchResultsCalendar ) GetPeriods () (value []SearchResultsCalendarPeriod ) {
if s == nil {
return
}
return s .Periods
}
func (s *MessagesSearchResultsCalendar ) GetMessages () (value []MessageClass ) {
if s == nil {
return
}
return s .Messages
}
func (s *MessagesSearchResultsCalendar ) GetChats () (value []ChatClass ) {
if s == nil {
return
}
return s .Chats
}
func (s *MessagesSearchResultsCalendar ) GetUsers () (value []UserClass ) {
if s == nil {
return
}
return s .Users
}
func (s *MessagesSearchResultsCalendar ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (s .Messages )
}
func (s *MessagesSearchResultsCalendar ) MapChats () (value ChatClassArray ) {
return ChatClassArray (s .Chats )
}
func (s *MessagesSearchResultsCalendar ) MapUsers () (value UserClassArray ) {
return UserClassArray (s .Users )
}
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 .