Files
mautrix-telegram/pkg/gotd/tdapi/tl_set_message_reactions_gen.go
T
2025-06-27 20:03:37 -07:00

340 lines
8.6 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tdapi
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// SetMessageReactionsRequest represents TL type `setMessageReactions#71fa9e8f`.
type SetMessageReactionsRequest struct {
// Identifier of the chat to which the message belongs
ChatID int64
// Identifier of the message
MessageID int64
// Types of the reaction to set; pass an empty list to remove the reactions
ReactionTypes []ReactionTypeClass
// Pass true if the reactions are added with a big animation
IsBig bool
}
// SetMessageReactionsRequestTypeID is TL type id of SetMessageReactionsRequest.
const SetMessageReactionsRequestTypeID = 0x71fa9e8f
// Ensuring interfaces in compile-time for SetMessageReactionsRequest.
var (
_ bin.Encoder = &SetMessageReactionsRequest{}
_ bin.Decoder = &SetMessageReactionsRequest{}
_ bin.BareEncoder = &SetMessageReactionsRequest{}
_ bin.BareDecoder = &SetMessageReactionsRequest{}
)
func (s *SetMessageReactionsRequest) Zero() bool {
if s == nil {
return true
}
if !(s.ChatID == 0) {
return false
}
if !(s.MessageID == 0) {
return false
}
if !(s.ReactionTypes == nil) {
return false
}
if !(s.IsBig == false) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *SetMessageReactionsRequest) String() string {
if s == nil {
return "SetMessageReactionsRequest(nil)"
}
type Alias SetMessageReactionsRequest
return fmt.Sprintf("SetMessageReactionsRequest%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*SetMessageReactionsRequest) TypeID() uint32 {
return SetMessageReactionsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*SetMessageReactionsRequest) TypeName() string {
return "setMessageReactions"
}
// TypeInfo returns info about TL type.
func (s *SetMessageReactionsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "setMessageReactions",
ID: SetMessageReactionsRequestTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ChatID",
SchemaName: "chat_id",
},
{
Name: "MessageID",
SchemaName: "message_id",
},
{
Name: "ReactionTypes",
SchemaName: "reaction_types",
},
{
Name: "IsBig",
SchemaName: "is_big",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *SetMessageReactionsRequest) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setMessageReactions#71fa9e8f as nil")
}
b.PutID(SetMessageReactionsRequestTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *SetMessageReactionsRequest) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode setMessageReactions#71fa9e8f as nil")
}
b.PutInt53(s.ChatID)
b.PutInt53(s.MessageID)
b.PutInt(len(s.ReactionTypes))
for idx, v := range s.ReactionTypes {
if v == nil {
return fmt.Errorf("unable to encode setMessageReactions#71fa9e8f: field reaction_types element with index %d is nil", idx)
}
if err := v.EncodeBare(b); err != nil {
return fmt.Errorf("unable to encode bare setMessageReactions#71fa9e8f: field reaction_types element with index %d: %w", idx, err)
}
}
b.PutBool(s.IsBig)
return nil
}
// Decode implements bin.Decoder.
func (s *SetMessageReactionsRequest) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setMessageReactions#71fa9e8f to nil")
}
if err := b.ConsumeID(SetMessageReactionsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *SetMessageReactionsRequest) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode setMessageReactions#71fa9e8f to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field chat_id: %w", err)
}
s.ChatID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field message_id: %w", err)
}
s.MessageID = value
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field reaction_types: %w", err)
}
if headerLen > 0 {
s.ReactionTypes = make([]ReactionTypeClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeReactionType(b)
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field reaction_types: %w", err)
}
s.ReactionTypes = append(s.ReactionTypes, value)
}
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field is_big: %w", err)
}
s.IsBig = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SetMessageReactionsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode setMessageReactions#71fa9e8f as nil")
}
b.ObjStart()
b.PutID("setMessageReactions")
b.Comma()
b.FieldStart("chat_id")
b.PutInt53(s.ChatID)
b.Comma()
b.FieldStart("message_id")
b.PutInt53(s.MessageID)
b.Comma()
b.FieldStart("reaction_types")
b.ArrStart()
for idx, v := range s.ReactionTypes {
if v == nil {
return fmt.Errorf("unable to encode setMessageReactions#71fa9e8f: field reaction_types element with index %d is nil", idx)
}
if err := v.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode setMessageReactions#71fa9e8f: field reaction_types element with index %d: %w", idx, err)
}
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.FieldStart("is_big")
b.PutBool(s.IsBig)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SetMessageReactionsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode setMessageReactions#71fa9e8f to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("setMessageReactions"); err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: %w", err)
}
case "chat_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field chat_id: %w", err)
}
s.ChatID = value
case "message_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field message_id: %w", err)
}
s.MessageID = value
case "reaction_types":
if err := b.Arr(func(b tdjson.Decoder) error {
value, err := DecodeTDLibJSONReactionType(b)
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field reaction_types: %w", err)
}
s.ReactionTypes = append(s.ReactionTypes, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field reaction_types: %w", err)
}
case "is_big":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode setMessageReactions#71fa9e8f: field is_big: %w", err)
}
s.IsBig = value
default:
return b.Skip()
}
return nil
})
}
// GetChatID returns value of ChatID field.
func (s *SetMessageReactionsRequest) GetChatID() (value int64) {
if s == nil {
return
}
return s.ChatID
}
// GetMessageID returns value of MessageID field.
func (s *SetMessageReactionsRequest) GetMessageID() (value int64) {
if s == nil {
return
}
return s.MessageID
}
// GetReactionTypes returns value of ReactionTypes field.
func (s *SetMessageReactionsRequest) GetReactionTypes() (value []ReactionTypeClass) {
if s == nil {
return
}
return s.ReactionTypes
}
// GetIsBig returns value of IsBig field.
func (s *SetMessageReactionsRequest) GetIsBig() (value bool) {
if s == nil {
return
}
return s.IsBig
}
// SetMessageReactions invokes method setMessageReactions#71fa9e8f returning error if any.
func (c *Client) SetMessageReactions(ctx context.Context, request *SetMessageReactionsRequest) error {
var ok Ok
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}