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 MessagesVotesList struct {
Flags bin .Fields
Count int
Votes []MessagePeerVoteClass
Chats []ChatClass
Users []UserClass
NextOffset string
}
const MessagesVotesListTypeID = 0x4899484e
var (
_ bin .Encoder = &MessagesVotesList {}
_ bin .Decoder = &MessagesVotesList {}
_ bin .BareEncoder = &MessagesVotesList {}
_ bin .BareDecoder = &MessagesVotesList {}
)
func (v *MessagesVotesList ) Zero () bool {
if v == nil {
return true
}
if !(v .Flags .Zero ()) {
return false
}
if !(v .Count == 0 ) {
return false
}
if !(v .Votes == nil ) {
return false
}
if !(v .Chats == nil ) {
return false
}
if !(v .Users == nil ) {
return false
}
if !(v .NextOffset == "" ) {
return false
}
return true
}
func (v *MessagesVotesList ) String () string {
if v == nil {
return "MessagesVotesList(nil)"
}
type Alias MessagesVotesList
return fmt .Sprintf ("MessagesVotesList%+v" , Alias (*v ))
}
func (v *MessagesVotesList ) FillFrom (from interface {
GetCount () (value int )
GetVotes () (value []MessagePeerVoteClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetNextOffset () (value string , ok bool )
}) {
v .Count = from .GetCount ()
v .Votes = from .GetVotes ()
v .Chats = from .GetChats ()
v .Users = from .GetUsers ()
if val , ok := from .GetNextOffset (); ok {
v .NextOffset = val
}
}
func (*MessagesVotesList ) TypeID () uint32 {
return MessagesVotesListTypeID
}
func (*MessagesVotesList ) TypeName () string {
return "messages.votesList"
}
func (v *MessagesVotesList ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.votesList" ,
ID : MessagesVotesListTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Votes" ,
SchemaName : "votes" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !v .Flags .Has (0 ),
},
}
return typ
}
func (v *MessagesVotesList ) SetFlags () {
if !(v .NextOffset == "" ) {
v .Flags .Set (0 )
}
}
func (v *MessagesVotesList ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode messages.votesList#4899484e as nil" )
}
b .PutID (MessagesVotesListTypeID )
return v .EncodeBare (b )
}
func (v *MessagesVotesList ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode messages.votesList#4899484e as nil" )
}
v .SetFlags ()
if err := v .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field flags: %w" , err )
}
b .PutInt (v .Count )
b .PutVectorHeader (len (v .Votes ))
for idx , v := range v .Votes {
if v == nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field votes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field votes element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (v .Chats ))
for idx , v := range v .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (v .Users ))
for idx , v := range v .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.votesList#4899484e: field users element with index %d: %w" , idx , err )
}
}
if v .Flags .Has (0 ) {
b .PutString (v .NextOffset )
}
return nil
}
func (v *MessagesVotesList ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode messages.votesList#4899484e to nil" )
}
if err := b .ConsumeID (MessagesVotesListTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: %w" , err )
}
return v .DecodeBare (b )
}
func (v *MessagesVotesList ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode messages.votesList#4899484e to nil" )
}
{
if err := v .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field count: %w" , err )
}
v .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field votes: %w" , err )
}
if headerLen > 0 {
v .Votes = make ([]MessagePeerVoteClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessagePeerVote (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field votes: %w" , err )
}
v .Votes = append (v .Votes , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field chats: %w" , err )
}
if headerLen > 0 {
v .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.votesList#4899484e: field chats: %w" , err )
}
v .Chats = append (v .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field users: %w" , err )
}
if headerLen > 0 {
v .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.votesList#4899484e: field users: %w" , err )
}
v .Users = append (v .Users , value )
}
}
if v .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.votesList#4899484e: field next_offset: %w" , err )
}
v .NextOffset = value
}
return nil
}
func (v *MessagesVotesList ) GetCount () (value int ) {
if v == nil {
return
}
return v .Count
}
func (v *MessagesVotesList ) GetVotes () (value []MessagePeerVoteClass ) {
if v == nil {
return
}
return v .Votes
}
func (v *MessagesVotesList ) GetChats () (value []ChatClass ) {
if v == nil {
return
}
return v .Chats
}
func (v *MessagesVotesList ) GetUsers () (value []UserClass ) {
if v == nil {
return
}
return v .Users
}
func (v *MessagesVotesList ) SetNextOffset (value string ) {
v .Flags .Set (0 )
v .NextOffset = value
}
func (v *MessagesVotesList ) GetNextOffset () (value string , ok bool ) {
if v == nil {
return
}
if !v .Flags .Has (0 ) {
return value , false
}
return v .NextOffset , true
}
func (v *MessagesVotesList ) MapVotes () (value MessagePeerVoteClassArray ) {
return MessagePeerVoteClassArray (v .Votes )
}
func (v *MessagesVotesList ) MapChats () (value ChatClassArray ) {
return ChatClassArray (v .Chats )
}
func (v *MessagesVotesList ) MapUsers () (value UserClassArray ) {
return UserClassArray (v .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 .