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 MessagesSendVoteRequest struct {
Peer InputPeerClass
MsgID int
Options [][]byte
}
const MessagesSendVoteRequestTypeID = 0x10ea6184
var (
_ bin .Encoder = &MessagesSendVoteRequest {}
_ bin .Decoder = &MessagesSendVoteRequest {}
_ bin .BareEncoder = &MessagesSendVoteRequest {}
_ bin .BareDecoder = &MessagesSendVoteRequest {}
)
func (s *MessagesSendVoteRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Peer == nil ) {
return false
}
if !(s .MsgID == 0 ) {
return false
}
if !(s .Options == nil ) {
return false
}
return true
}
func (s *MessagesSendVoteRequest ) String () string {
if s == nil {
return "MessagesSendVoteRequest(nil)"
}
type Alias MessagesSendVoteRequest
return fmt .Sprintf ("MessagesSendVoteRequest%+v" , Alias (*s ))
}
func (s *MessagesSendVoteRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetMsgID () (value int )
GetOptions () (value [][]byte )
}) {
s .Peer = from .GetPeer ()
s .MsgID = from .GetMsgID ()
s .Options = from .GetOptions ()
}
func (*MessagesSendVoteRequest ) TypeID () uint32 {
return MessagesSendVoteRequestTypeID
}
func (*MessagesSendVoteRequest ) TypeName () string {
return "messages.sendVote"
}
func (s *MessagesSendVoteRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendVote" ,
ID : MessagesSendVoteRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "Options" ,
SchemaName : "options" ,
},
}
return typ
}
func (s *MessagesSendVoteRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendVote#10ea6184 as nil" )
}
b .PutID (MessagesSendVoteRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendVoteRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendVote#10ea6184 as nil" )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.sendVote#10ea6184: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendVote#10ea6184: field peer: %w" , err )
}
b .PutInt (s .MsgID )
b .PutVectorHeader (len (s .Options ))
for _ , v := range s .Options {
b .PutBytes (v )
}
return nil
}
func (s *MessagesSendVoteRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendVote#10ea6184 to nil" )
}
if err := b .ConsumeID (MessagesSendVoteRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendVote#10ea6184: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendVoteRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendVote#10ea6184 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendVote#10ea6184: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendVote#10ea6184: field msg_id: %w" , err )
}
s .MsgID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendVote#10ea6184: field options: %w" , err )
}
if headerLen > 0 {
s .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 messages.sendVote#10ea6184: field options: %w" , err )
}
s .Options = append (s .Options , value )
}
}
return nil
}
func (s *MessagesSendVoteRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendVoteRequest ) GetMsgID () (value int ) {
if s == nil {
return
}
return s .MsgID
}
func (s *MessagesSendVoteRequest ) GetOptions () (value [][]byte ) {
if s == nil {
return
}
return s .Options
}
func (c *Client ) MessagesSendVote (ctx context .Context , request *MessagesSendVoteRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .