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 MessagesSendReactionRequest struct {
Flags bin .Fields
Big bool
AddToRecent bool
Peer InputPeerClass
MsgID int
Reaction []ReactionClass
}
const MessagesSendReactionRequestTypeID = 0xd30d78d4
var (
_ bin .Encoder = &MessagesSendReactionRequest {}
_ bin .Decoder = &MessagesSendReactionRequest {}
_ bin .BareEncoder = &MessagesSendReactionRequest {}
_ bin .BareDecoder = &MessagesSendReactionRequest {}
)
func (s *MessagesSendReactionRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Big == false ) {
return false
}
if !(s .AddToRecent == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .MsgID == 0 ) {
return false
}
if !(s .Reaction == nil ) {
return false
}
return true
}
func (s *MessagesSendReactionRequest ) String () string {
if s == nil {
return "MessagesSendReactionRequest(nil)"
}
type Alias MessagesSendReactionRequest
return fmt .Sprintf ("MessagesSendReactionRequest%+v" , Alias (*s ))
}
func (s *MessagesSendReactionRequest ) FillFrom (from interface {
GetBig () (value bool )
GetAddToRecent () (value bool )
GetPeer () (value InputPeerClass )
GetMsgID () (value int )
GetReaction () (value []ReactionClass , ok bool )
}) {
s .Big = from .GetBig ()
s .AddToRecent = from .GetAddToRecent ()
s .Peer = from .GetPeer ()
s .MsgID = from .GetMsgID ()
if val , ok := from .GetReaction (); ok {
s .Reaction = val
}
}
func (*MessagesSendReactionRequest ) TypeID () uint32 {
return MessagesSendReactionRequestTypeID
}
func (*MessagesSendReactionRequest ) TypeName () string {
return "messages.sendReaction"
}
func (s *MessagesSendReactionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendReaction" ,
ID : MessagesSendReactionRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Big" ,
SchemaName : "big" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "AddToRecent" ,
SchemaName : "add_to_recent" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "Reaction" ,
SchemaName : "reaction" ,
Null : !s .Flags .Has (0 ),
},
}
return typ
}
func (s *MessagesSendReactionRequest ) SetFlags () {
if !(s .Big == false ) {
s .Flags .Set (1 )
}
if !(s .AddToRecent == false ) {
s .Flags .Set (2 )
}
if !(s .Reaction == nil ) {
s .Flags .Set (0 )
}
}
func (s *MessagesSendReactionRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendReaction#d30d78d4 as nil" )
}
b .PutID (MessagesSendReactionRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendReactionRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendReaction#d30d78d4 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendReaction#d30d78d4: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.sendReaction#d30d78d4: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendReaction#d30d78d4: field peer: %w" , err )
}
b .PutInt (s .MsgID )
if s .Flags .Has (0 ) {
b .PutVectorHeader (len (s .Reaction ))
for idx , v := range s .Reaction {
if v == nil {
return fmt .Errorf ("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (s *MessagesSendReactionRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendReaction#d30d78d4 to nil" )
}
if err := b .ConsumeID (MessagesSendReactionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendReactionRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendReaction#d30d78d4 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: field flags: %w" , err )
}
}
s .Big = s .Flags .Has (1 )
s .AddToRecent = s .Flags .Has (2 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: field msg_id: %w" , err )
}
s .MsgID = value
}
if s .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: field reaction: %w" , err )
}
if headerLen > 0 {
s .Reaction = make ([]ReactionClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeReaction (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendReaction#d30d78d4: field reaction: %w" , err )
}
s .Reaction = append (s .Reaction , value )
}
}
return nil
}
func (s *MessagesSendReactionRequest ) SetBig (value bool ) {
if value {
s .Flags .Set (1 )
s .Big = true
} else {
s .Flags .Unset (1 )
s .Big = false
}
}
func (s *MessagesSendReactionRequest ) GetBig () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSendReactionRequest ) SetAddToRecent (value bool ) {
if value {
s .Flags .Set (2 )
s .AddToRecent = true
} else {
s .Flags .Unset (2 )
s .AddToRecent = false
}
}
func (s *MessagesSendReactionRequest ) GetAddToRecent () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (2 )
}
func (s *MessagesSendReactionRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendReactionRequest ) GetMsgID () (value int ) {
if s == nil {
return
}
return s .MsgID
}
func (s *MessagesSendReactionRequest ) SetReaction (value []ReactionClass ) {
s .Flags .Set (0 )
s .Reaction = value
}
func (s *MessagesSendReactionRequest ) GetReaction () (value []ReactionClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Reaction , true
}
func (s *MessagesSendReactionRequest ) MapReaction () (value ReactionClassArray , ok bool ) {
if !s .Flags .Has (0 ) {
return value , false
}
return ReactionClassArray (s .Reaction ), true
}
func (c *Client ) MessagesSendReaction (ctx context .Context , request *MessagesSendReactionRequest ) (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 .