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 MessagePeerVote struct {
Peer PeerClass
Option []byte
Date int
}
const MessagePeerVoteTypeID = 0xb6cc2d5c
func (m MessagePeerVote ) construct () MessagePeerVoteClass { return &m }
var (
_ bin .Encoder = &MessagePeerVote {}
_ bin .Decoder = &MessagePeerVote {}
_ bin .BareEncoder = &MessagePeerVote {}
_ bin .BareDecoder = &MessagePeerVote {}
_ MessagePeerVoteClass = &MessagePeerVote {}
)
func (m *MessagePeerVote ) Zero () bool {
if m == nil {
return true
}
if !(m .Peer == nil ) {
return false
}
if !(m .Option == nil ) {
return false
}
if !(m .Date == 0 ) {
return false
}
return true
}
func (m *MessagePeerVote ) String () string {
if m == nil {
return "MessagePeerVote(nil)"
}
type Alias MessagePeerVote
return fmt .Sprintf ("MessagePeerVote%+v" , Alias (*m ))
}
func (m *MessagePeerVote ) FillFrom (from interface {
GetPeer () (value PeerClass )
GetOption () (value []byte )
GetDate () (value int )
}) {
m .Peer = from .GetPeer ()
m .Option = from .GetOption ()
m .Date = from .GetDate ()
}
func (*MessagePeerVote ) TypeID () uint32 {
return MessagePeerVoteTypeID
}
func (*MessagePeerVote ) TypeName () string {
return "messagePeerVote"
}
func (m *MessagePeerVote ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messagePeerVote" ,
ID : MessagePeerVoteTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Option" ,
SchemaName : "option" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (m *MessagePeerVote ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVote#b6cc2d5c as nil" )
}
b .PutID (MessagePeerVoteTypeID )
return m .EncodeBare (b )
}
func (m *MessagePeerVote ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVote#b6cc2d5c as nil" )
}
if m .Peer == nil {
return fmt .Errorf ("unable to encode messagePeerVote#b6cc2d5c: field peer is nil" )
}
if err := m .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messagePeerVote#b6cc2d5c: field peer: %w" , err )
}
b .PutBytes (m .Option )
b .PutInt (m .Date )
return nil
}
func (m *MessagePeerVote ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVote#b6cc2d5c to nil" )
}
if err := b .ConsumeID (MessagePeerVoteTypeID ); err != nil {
return fmt .Errorf ("unable to decode messagePeerVote#b6cc2d5c: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagePeerVote ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVote#b6cc2d5c to nil" )
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVote#b6cc2d5c: field peer: %w" , err )
}
m .Peer = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVote#b6cc2d5c: field option: %w" , err )
}
m .Option = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVote#b6cc2d5c: field date: %w" , err )
}
m .Date = value
}
return nil
}
func (m *MessagePeerVote ) GetPeer () (value PeerClass ) {
if m == nil {
return
}
return m .Peer
}
func (m *MessagePeerVote ) GetOption () (value []byte ) {
if m == nil {
return
}
return m .Option
}
func (m *MessagePeerVote ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
type MessagePeerVoteInputOption struct {
Peer PeerClass
Date int
}
const MessagePeerVoteInputOptionTypeID = 0x74cda504
func (m MessagePeerVoteInputOption ) construct () MessagePeerVoteClass { return &m }
var (
_ bin .Encoder = &MessagePeerVoteInputOption {}
_ bin .Decoder = &MessagePeerVoteInputOption {}
_ bin .BareEncoder = &MessagePeerVoteInputOption {}
_ bin .BareDecoder = &MessagePeerVoteInputOption {}
_ MessagePeerVoteClass = &MessagePeerVoteInputOption {}
)
func (m *MessagePeerVoteInputOption ) Zero () bool {
if m == nil {
return true
}
if !(m .Peer == nil ) {
return false
}
if !(m .Date == 0 ) {
return false
}
return true
}
func (m *MessagePeerVoteInputOption ) String () string {
if m == nil {
return "MessagePeerVoteInputOption(nil)"
}
type Alias MessagePeerVoteInputOption
return fmt .Sprintf ("MessagePeerVoteInputOption%+v" , Alias (*m ))
}
func (m *MessagePeerVoteInputOption ) FillFrom (from interface {
GetPeer () (value PeerClass )
GetDate () (value int )
}) {
m .Peer = from .GetPeer ()
m .Date = from .GetDate ()
}
func (*MessagePeerVoteInputOption ) TypeID () uint32 {
return MessagePeerVoteInputOptionTypeID
}
func (*MessagePeerVoteInputOption ) TypeName () string {
return "messagePeerVoteInputOption"
}
func (m *MessagePeerVoteInputOption ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messagePeerVoteInputOption" ,
ID : MessagePeerVoteInputOptionTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (m *MessagePeerVoteInputOption ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVoteInputOption#74cda504 as nil" )
}
b .PutID (MessagePeerVoteInputOptionTypeID )
return m .EncodeBare (b )
}
func (m *MessagePeerVoteInputOption ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVoteInputOption#74cda504 as nil" )
}
if m .Peer == nil {
return fmt .Errorf ("unable to encode messagePeerVoteInputOption#74cda504: field peer is nil" )
}
if err := m .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messagePeerVoteInputOption#74cda504: field peer: %w" , err )
}
b .PutInt (m .Date )
return nil
}
func (m *MessagePeerVoteInputOption ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVoteInputOption#74cda504 to nil" )
}
if err := b .ConsumeID (MessagePeerVoteInputOptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteInputOption#74cda504: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagePeerVoteInputOption ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVoteInputOption#74cda504 to nil" )
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteInputOption#74cda504: field peer: %w" , err )
}
m .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteInputOption#74cda504: field date: %w" , err )
}
m .Date = value
}
return nil
}
func (m *MessagePeerVoteInputOption ) GetPeer () (value PeerClass ) {
if m == nil {
return
}
return m .Peer
}
func (m *MessagePeerVoteInputOption ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
type MessagePeerVoteMultiple struct {
Peer PeerClass
Options [][]byte
Date int
}
const MessagePeerVoteMultipleTypeID = 0x4628f6e6
func (m MessagePeerVoteMultiple ) construct () MessagePeerVoteClass { return &m }
var (
_ bin .Encoder = &MessagePeerVoteMultiple {}
_ bin .Decoder = &MessagePeerVoteMultiple {}
_ bin .BareEncoder = &MessagePeerVoteMultiple {}
_ bin .BareDecoder = &MessagePeerVoteMultiple {}
_ MessagePeerVoteClass = &MessagePeerVoteMultiple {}
)
func (m *MessagePeerVoteMultiple ) Zero () bool {
if m == nil {
return true
}
if !(m .Peer == nil ) {
return false
}
if !(m .Options == nil ) {
return false
}
if !(m .Date == 0 ) {
return false
}
return true
}
func (m *MessagePeerVoteMultiple ) String () string {
if m == nil {
return "MessagePeerVoteMultiple(nil)"
}
type Alias MessagePeerVoteMultiple
return fmt .Sprintf ("MessagePeerVoteMultiple%+v" , Alias (*m ))
}
func (m *MessagePeerVoteMultiple ) FillFrom (from interface {
GetPeer () (value PeerClass )
GetOptions () (value [][]byte )
GetDate () (value int )
}) {
m .Peer = from .GetPeer ()
m .Options = from .GetOptions ()
m .Date = from .GetDate ()
}
func (*MessagePeerVoteMultiple ) TypeID () uint32 {
return MessagePeerVoteMultipleTypeID
}
func (*MessagePeerVoteMultiple ) TypeName () string {
return "messagePeerVoteMultiple"
}
func (m *MessagePeerVoteMultiple ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messagePeerVoteMultiple" ,
ID : MessagePeerVoteMultipleTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Options" ,
SchemaName : "options" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (m *MessagePeerVoteMultiple ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVoteMultiple#4628f6e6 as nil" )
}
b .PutID (MessagePeerVoteMultipleTypeID )
return m .EncodeBare (b )
}
func (m *MessagePeerVoteMultiple ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messagePeerVoteMultiple#4628f6e6 as nil" )
}
if m .Peer == nil {
return fmt .Errorf ("unable to encode messagePeerVoteMultiple#4628f6e6: field peer is nil" )
}
if err := m .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messagePeerVoteMultiple#4628f6e6: field peer: %w" , err )
}
b .PutVectorHeader (len (m .Options ))
for _ , v := range m .Options {
b .PutBytes (v )
}
b .PutInt (m .Date )
return nil
}
func (m *MessagePeerVoteMultiple ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVoteMultiple#4628f6e6 to nil" )
}
if err := b .ConsumeID (MessagePeerVoteMultipleTypeID ); err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteMultiple#4628f6e6: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagePeerVoteMultiple ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messagePeerVoteMultiple#4628f6e6 to nil" )
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteMultiple#4628f6e6: field peer: %w" , err )
}
m .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteMultiple#4628f6e6: field options: %w" , err )
}
if headerLen > 0 {
m .Options = make ([][]byte , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteMultiple#4628f6e6: field options: %w" , err )
}
m .Options = append (m .Options , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messagePeerVoteMultiple#4628f6e6: field date: %w" , err )
}
m .Date = value
}
return nil
}
func (m *MessagePeerVoteMultiple ) GetPeer () (value PeerClass ) {
if m == nil {
return
}
return m .Peer
}
func (m *MessagePeerVoteMultiple ) GetOptions () (value [][]byte ) {
if m == nil {
return
}
return m .Options
}
func (m *MessagePeerVoteMultiple ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
const MessagePeerVoteClassName = "MessagePeerVote"
type MessagePeerVoteClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagePeerVoteClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetPeer () (value PeerClass )
GetDate () (value int )
}
func DecodeMessagePeerVote (buf *bin .Buffer ) (MessagePeerVoteClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagePeerVoteTypeID :
v := MessagePeerVote {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagePeerVoteClass: %w" , err )
}
return &v , nil
case MessagePeerVoteInputOptionTypeID :
v := MessagePeerVoteInputOption {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagePeerVoteClass: %w" , err )
}
return &v , nil
case MessagePeerVoteMultipleTypeID :
v := MessagePeerVoteMultiple {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagePeerVoteClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagePeerVoteClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagePeerVoteBox struct {
MessagePeerVote MessagePeerVoteClass
}
func (b *MessagePeerVoteBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagePeerVoteBox to nil" )
}
v , err := DecodeMessagePeerVote (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .MessagePeerVote = v
return nil
}
func (b *MessagePeerVoteBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .MessagePeerVote == nil {
return fmt .Errorf ("unable to encode MessagePeerVoteClass as nil" )
}
return b .MessagePeerVote .Encode (buf )
}
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 .