7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
352 lines
8.8 KiB
Go
352 lines
8.8 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{}
|
|
)
|
|
|
|
// AddMessageReactionRequest represents TL type `addMessageReaction#549855ed`.
|
|
type AddMessageReactionRequest struct {
|
|
// Identifier of the chat to which the message belongs
|
|
ChatID int64
|
|
// Identifier of the message
|
|
MessageID int64
|
|
// Type of the reaction to add. Use addPendingPaidMessageReaction instead to add the paid
|
|
// reaction
|
|
ReactionType ReactionTypeClass
|
|
// Pass true if the reaction is added with a big animation
|
|
IsBig bool
|
|
// Pass true if the reaction needs to be added to recent reactions; tags are never added
|
|
// to the list of recent reactions
|
|
UpdateRecentReactions bool
|
|
}
|
|
|
|
// AddMessageReactionRequestTypeID is TL type id of AddMessageReactionRequest.
|
|
const AddMessageReactionRequestTypeID = 0x549855ed
|
|
|
|
// Ensuring interfaces in compile-time for AddMessageReactionRequest.
|
|
var (
|
|
_ bin.Encoder = &AddMessageReactionRequest{}
|
|
_ bin.Decoder = &AddMessageReactionRequest{}
|
|
_ bin.BareEncoder = &AddMessageReactionRequest{}
|
|
_ bin.BareDecoder = &AddMessageReactionRequest{}
|
|
)
|
|
|
|
func (a *AddMessageReactionRequest) Zero() bool {
|
|
if a == nil {
|
|
return true
|
|
}
|
|
if !(a.ChatID == 0) {
|
|
return false
|
|
}
|
|
if !(a.MessageID == 0) {
|
|
return false
|
|
}
|
|
if !(a.ReactionType == nil) {
|
|
return false
|
|
}
|
|
if !(a.IsBig == false) {
|
|
return false
|
|
}
|
|
if !(a.UpdateRecentReactions == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (a *AddMessageReactionRequest) String() string {
|
|
if a == nil {
|
|
return "AddMessageReactionRequest(nil)"
|
|
}
|
|
type Alias AddMessageReactionRequest
|
|
return fmt.Sprintf("AddMessageReactionRequest%+v", Alias(*a))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*AddMessageReactionRequest) TypeID() uint32 {
|
|
return AddMessageReactionRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*AddMessageReactionRequest) TypeName() string {
|
|
return "addMessageReaction"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (a *AddMessageReactionRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "addMessageReaction",
|
|
ID: AddMessageReactionRequestTypeID,
|
|
}
|
|
if a == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "ChatID",
|
|
SchemaName: "chat_id",
|
|
},
|
|
{
|
|
Name: "MessageID",
|
|
SchemaName: "message_id",
|
|
},
|
|
{
|
|
Name: "ReactionType",
|
|
SchemaName: "reaction_type",
|
|
},
|
|
{
|
|
Name: "IsBig",
|
|
SchemaName: "is_big",
|
|
},
|
|
{
|
|
Name: "UpdateRecentReactions",
|
|
SchemaName: "update_recent_reactions",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (a *AddMessageReactionRequest) Encode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode addMessageReaction#549855ed as nil")
|
|
}
|
|
b.PutID(AddMessageReactionRequestTypeID)
|
|
return a.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (a *AddMessageReactionRequest) EncodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode addMessageReaction#549855ed as nil")
|
|
}
|
|
b.PutInt53(a.ChatID)
|
|
b.PutInt53(a.MessageID)
|
|
if a.ReactionType == nil {
|
|
return fmt.Errorf("unable to encode addMessageReaction#549855ed: field reaction_type is nil")
|
|
}
|
|
if err := a.ReactionType.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode addMessageReaction#549855ed: field reaction_type: %w", err)
|
|
}
|
|
b.PutBool(a.IsBig)
|
|
b.PutBool(a.UpdateRecentReactions)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (a *AddMessageReactionRequest) Decode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode addMessageReaction#549855ed to nil")
|
|
}
|
|
if err := b.ConsumeID(AddMessageReactionRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: %w", err)
|
|
}
|
|
return a.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (a *AddMessageReactionRequest) DecodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode addMessageReaction#549855ed to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field chat_id: %w", err)
|
|
}
|
|
a.ChatID = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field message_id: %w", err)
|
|
}
|
|
a.MessageID = value
|
|
}
|
|
{
|
|
value, err := DecodeReactionType(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field reaction_type: %w", err)
|
|
}
|
|
a.ReactionType = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field is_big: %w", err)
|
|
}
|
|
a.IsBig = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field update_recent_reactions: %w", err)
|
|
}
|
|
a.UpdateRecentReactions = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (a *AddMessageReactionRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode addMessageReaction#549855ed as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("addMessageReaction")
|
|
b.Comma()
|
|
b.FieldStart("chat_id")
|
|
b.PutInt53(a.ChatID)
|
|
b.Comma()
|
|
b.FieldStart("message_id")
|
|
b.PutInt53(a.MessageID)
|
|
b.Comma()
|
|
b.FieldStart("reaction_type")
|
|
if a.ReactionType == nil {
|
|
return fmt.Errorf("unable to encode addMessageReaction#549855ed: field reaction_type is nil")
|
|
}
|
|
if err := a.ReactionType.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode addMessageReaction#549855ed: field reaction_type: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("is_big")
|
|
b.PutBool(a.IsBig)
|
|
b.Comma()
|
|
b.FieldStart("update_recent_reactions")
|
|
b.PutBool(a.UpdateRecentReactions)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (a *AddMessageReactionRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode addMessageReaction#549855ed to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("addMessageReaction"); err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: %w", err)
|
|
}
|
|
case "chat_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field chat_id: %w", err)
|
|
}
|
|
a.ChatID = value
|
|
case "message_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field message_id: %w", err)
|
|
}
|
|
a.MessageID = value
|
|
case "reaction_type":
|
|
value, err := DecodeTDLibJSONReactionType(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field reaction_type: %w", err)
|
|
}
|
|
a.ReactionType = value
|
|
case "is_big":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field is_big: %w", err)
|
|
}
|
|
a.IsBig = value
|
|
case "update_recent_reactions":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode addMessageReaction#549855ed: field update_recent_reactions: %w", err)
|
|
}
|
|
a.UpdateRecentReactions = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetChatID returns value of ChatID field.
|
|
func (a *AddMessageReactionRequest) GetChatID() (value int64) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.ChatID
|
|
}
|
|
|
|
// GetMessageID returns value of MessageID field.
|
|
func (a *AddMessageReactionRequest) GetMessageID() (value int64) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.MessageID
|
|
}
|
|
|
|
// GetReactionType returns value of ReactionType field.
|
|
func (a *AddMessageReactionRequest) GetReactionType() (value ReactionTypeClass) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.ReactionType
|
|
}
|
|
|
|
// GetIsBig returns value of IsBig field.
|
|
func (a *AddMessageReactionRequest) GetIsBig() (value bool) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.IsBig
|
|
}
|
|
|
|
// GetUpdateRecentReactions returns value of UpdateRecentReactions field.
|
|
func (a *AddMessageReactionRequest) GetUpdateRecentReactions() (value bool) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.UpdateRecentReactions
|
|
}
|
|
|
|
// AddMessageReaction invokes method addMessageReaction#549855ed returning error if any.
|
|
func (c *Client) AddMessageReaction(ctx context.Context, request *AddMessageReactionRequest) error {
|
|
var ok Ok
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|