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
451 lines
11 KiB
Go
Generated
451 lines
11 KiB
Go
Generated
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tg
|
|
|
|
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{}
|
|
)
|
|
|
|
// MessageReactions represents TL type `messageReactions#a339f0b`.
|
|
// Message reactions »¹
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/reactions
|
|
//
|
|
// See https://core.telegram.org/constructor/messageReactions for reference.
|
|
type MessageReactions struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Similar to min¹ objects, used for message reaction »² constructors that are the
|
|
// same for all users so they don't have the reactions sent by the current user (you can
|
|
// use messages.getMessagesReactions³ to get the full reaction info).
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/min
|
|
// 2) https://core.telegram.org/api/reactions
|
|
// 3) https://core.telegram.org/method/messages.getMessagesReactions
|
|
Min bool
|
|
// Whether messages.getMessageReactionsList¹ can be used to see how each specific peer
|
|
// reacted to the message
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/method/messages.getMessageReactionsList
|
|
CanSeeList bool
|
|
// If set or if there are no reactions, all present and future reactions should be
|
|
// treated as message tags, see here » for more info¹.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/saved-messages#tags
|
|
ReactionsAsTags bool
|
|
// Reactions
|
|
Results []ReactionCount
|
|
// List of recent peers and their reactions
|
|
//
|
|
// Use SetRecentReactions and GetRecentReactions helpers.
|
|
RecentReactions []MessagePeerReaction
|
|
// Paid Telegram Star reactions leaderboard »¹ for this message.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/reactions#paid-reactions
|
|
//
|
|
// Use SetTopReactors and GetTopReactors helpers.
|
|
TopReactors []MessageReactor
|
|
}
|
|
|
|
// MessageReactionsTypeID is TL type id of MessageReactions.
|
|
const MessageReactionsTypeID = 0xa339f0b
|
|
|
|
// Ensuring interfaces in compile-time for MessageReactions.
|
|
var (
|
|
_ bin.Encoder = &MessageReactions{}
|
|
_ bin.Decoder = &MessageReactions{}
|
|
_ bin.BareEncoder = &MessageReactions{}
|
|
_ bin.BareDecoder = &MessageReactions{}
|
|
)
|
|
|
|
func (m *MessageReactions) Zero() bool {
|
|
if m == nil {
|
|
return true
|
|
}
|
|
if !(m.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(m.Min == false) {
|
|
return false
|
|
}
|
|
if !(m.CanSeeList == false) {
|
|
return false
|
|
}
|
|
if !(m.ReactionsAsTags == false) {
|
|
return false
|
|
}
|
|
if !(m.Results == nil) {
|
|
return false
|
|
}
|
|
if !(m.RecentReactions == nil) {
|
|
return false
|
|
}
|
|
if !(m.TopReactors == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (m *MessageReactions) String() string {
|
|
if m == nil {
|
|
return "MessageReactions(nil)"
|
|
}
|
|
type Alias MessageReactions
|
|
return fmt.Sprintf("MessageReactions%+v", Alias(*m))
|
|
}
|
|
|
|
// FillFrom fills MessageReactions from given interface.
|
|
func (m *MessageReactions) FillFrom(from interface {
|
|
GetMin() (value bool)
|
|
GetCanSeeList() (value bool)
|
|
GetReactionsAsTags() (value bool)
|
|
GetResults() (value []ReactionCount)
|
|
GetRecentReactions() (value []MessagePeerReaction, ok bool)
|
|
GetTopReactors() (value []MessageReactor, ok bool)
|
|
}) {
|
|
m.Min = from.GetMin()
|
|
m.CanSeeList = from.GetCanSeeList()
|
|
m.ReactionsAsTags = from.GetReactionsAsTags()
|
|
m.Results = from.GetResults()
|
|
if val, ok := from.GetRecentReactions(); ok {
|
|
m.RecentReactions = val
|
|
}
|
|
|
|
if val, ok := from.GetTopReactors(); ok {
|
|
m.TopReactors = val
|
|
}
|
|
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*MessageReactions) TypeID() uint32 {
|
|
return MessageReactionsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*MessageReactions) TypeName() string {
|
|
return "messageReactions"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (m *MessageReactions) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "messageReactions",
|
|
ID: MessageReactionsTypeID,
|
|
}
|
|
if m == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Min",
|
|
SchemaName: "min",
|
|
Null: !m.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "CanSeeList",
|
|
SchemaName: "can_see_list",
|
|
Null: !m.Flags.Has(2),
|
|
},
|
|
{
|
|
Name: "ReactionsAsTags",
|
|
SchemaName: "reactions_as_tags",
|
|
Null: !m.Flags.Has(3),
|
|
},
|
|
{
|
|
Name: "Results",
|
|
SchemaName: "results",
|
|
},
|
|
{
|
|
Name: "RecentReactions",
|
|
SchemaName: "recent_reactions",
|
|
Null: !m.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "TopReactors",
|
|
SchemaName: "top_reactors",
|
|
Null: !m.Flags.Has(4),
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (m *MessageReactions) SetFlags() {
|
|
if !(m.Min == false) {
|
|
m.Flags.Set(0)
|
|
}
|
|
if !(m.CanSeeList == false) {
|
|
m.Flags.Set(2)
|
|
}
|
|
if !(m.ReactionsAsTags == false) {
|
|
m.Flags.Set(3)
|
|
}
|
|
if !(m.RecentReactions == nil) {
|
|
m.Flags.Set(1)
|
|
}
|
|
if !(m.TopReactors == nil) {
|
|
m.Flags.Set(4)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (m *MessageReactions) Encode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode messageReactions#a339f0b as nil")
|
|
}
|
|
b.PutID(MessageReactionsTypeID)
|
|
return m.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (m *MessageReactions) EncodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode messageReactions#a339f0b as nil")
|
|
}
|
|
m.SetFlags()
|
|
if err := m.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messageReactions#a339f0b: field flags: %w", err)
|
|
}
|
|
b.PutVectorHeader(len(m.Results))
|
|
for idx, v := range m.Results {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messageReactions#a339f0b: field results element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
if m.Flags.Has(1) {
|
|
b.PutVectorHeader(len(m.RecentReactions))
|
|
for idx, v := range m.RecentReactions {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messageReactions#a339f0b: field recent_reactions element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Flags.Has(4) {
|
|
b.PutVectorHeader(len(m.TopReactors))
|
|
for idx, v := range m.TopReactors {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messageReactions#a339f0b: field top_reactors element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (m *MessageReactions) Decode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode messageReactions#a339f0b to nil")
|
|
}
|
|
if err := b.ConsumeID(MessageReactionsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: %w", err)
|
|
}
|
|
return m.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (m *MessageReactions) DecodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode messageReactions#a339f0b to nil")
|
|
}
|
|
{
|
|
if err := m.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field flags: %w", err)
|
|
}
|
|
}
|
|
m.Min = m.Flags.Has(0)
|
|
m.CanSeeList = m.Flags.Has(2)
|
|
m.ReactionsAsTags = m.Flags.Has(3)
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field results: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
m.Results = make([]ReactionCount, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value ReactionCount
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field results: %w", err)
|
|
}
|
|
m.Results = append(m.Results, value)
|
|
}
|
|
}
|
|
if m.Flags.Has(1) {
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field recent_reactions: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
m.RecentReactions = make([]MessagePeerReaction, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value MessagePeerReaction
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field recent_reactions: %w", err)
|
|
}
|
|
m.RecentReactions = append(m.RecentReactions, value)
|
|
}
|
|
}
|
|
if m.Flags.Has(4) {
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field top_reactors: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
m.TopReactors = make([]MessageReactor, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value MessageReactor
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messageReactions#a339f0b: field top_reactors: %w", err)
|
|
}
|
|
m.TopReactors = append(m.TopReactors, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetMin sets value of Min conditional field.
|
|
func (m *MessageReactions) SetMin(value bool) {
|
|
if value {
|
|
m.Flags.Set(0)
|
|
m.Min = true
|
|
} else {
|
|
m.Flags.Unset(0)
|
|
m.Min = false
|
|
}
|
|
}
|
|
|
|
// GetMin returns value of Min conditional field.
|
|
func (m *MessageReactions) GetMin() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(0)
|
|
}
|
|
|
|
// SetCanSeeList sets value of CanSeeList conditional field.
|
|
func (m *MessageReactions) SetCanSeeList(value bool) {
|
|
if value {
|
|
m.Flags.Set(2)
|
|
m.CanSeeList = true
|
|
} else {
|
|
m.Flags.Unset(2)
|
|
m.CanSeeList = false
|
|
}
|
|
}
|
|
|
|
// GetCanSeeList returns value of CanSeeList conditional field.
|
|
func (m *MessageReactions) GetCanSeeList() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(2)
|
|
}
|
|
|
|
// SetReactionsAsTags sets value of ReactionsAsTags conditional field.
|
|
func (m *MessageReactions) SetReactionsAsTags(value bool) {
|
|
if value {
|
|
m.Flags.Set(3)
|
|
m.ReactionsAsTags = true
|
|
} else {
|
|
m.Flags.Unset(3)
|
|
m.ReactionsAsTags = false
|
|
}
|
|
}
|
|
|
|
// GetReactionsAsTags returns value of ReactionsAsTags conditional field.
|
|
func (m *MessageReactions) GetReactionsAsTags() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(3)
|
|
}
|
|
|
|
// GetResults returns value of Results field.
|
|
func (m *MessageReactions) GetResults() (value []ReactionCount) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Results
|
|
}
|
|
|
|
// SetRecentReactions sets value of RecentReactions conditional field.
|
|
func (m *MessageReactions) SetRecentReactions(value []MessagePeerReaction) {
|
|
m.Flags.Set(1)
|
|
m.RecentReactions = value
|
|
}
|
|
|
|
// GetRecentReactions returns value of RecentReactions conditional field and
|
|
// boolean which is true if field was set.
|
|
func (m *MessageReactions) GetRecentReactions() (value []MessagePeerReaction, ok bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
if !m.Flags.Has(1) {
|
|
return value, false
|
|
}
|
|
return m.RecentReactions, true
|
|
}
|
|
|
|
// SetTopReactors sets value of TopReactors conditional field.
|
|
func (m *MessageReactions) SetTopReactors(value []MessageReactor) {
|
|
m.Flags.Set(4)
|
|
m.TopReactors = value
|
|
}
|
|
|
|
// GetTopReactors returns value of TopReactors conditional field and
|
|
// boolean which is true if field was set.
|
|
func (m *MessageReactions) GetTopReactors() (value []MessageReactor, ok bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
if !m.Flags.Has(4) {
|
|
return value, false
|
|
}
|
|
return m.TopReactors, true
|
|
}
|