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
363 lines
8.2 KiB
Go
363 lines
8.2 KiB
Go
// 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{}
|
|
)
|
|
|
|
// MessagePeerReaction represents TL type `messagePeerReaction#8c79b63c`.
|
|
// How a certain peer reacted to the message
|
|
//
|
|
// See https://core.telegram.org/constructor/messagePeerReaction for reference.
|
|
type MessagePeerReaction struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// Whether the specified message reaction »¹ should elicit a bigger and longer reaction
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/reactions
|
|
Big bool
|
|
// Whether the reaction wasn't yet marked as read by the current user
|
|
Unread bool
|
|
// Starting from layer 159, messages.sendReaction¹ will send reactions from the peer
|
|
// (user or channel) specified using messages.saveDefaultSendAs². If set, this flag
|
|
// indicates that this reaction was sent by us, even if the peer doesn't point to the
|
|
// current account.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/method/messages.sendReaction
|
|
// 2) https://core.telegram.org/method/messages.saveDefaultSendAs
|
|
My bool
|
|
// Peer that reacted to the message
|
|
PeerID PeerClass
|
|
// When was this reaction added
|
|
Date int
|
|
// Reaction emoji
|
|
Reaction ReactionClass
|
|
}
|
|
|
|
// MessagePeerReactionTypeID is TL type id of MessagePeerReaction.
|
|
const MessagePeerReactionTypeID = 0x8c79b63c
|
|
|
|
// Ensuring interfaces in compile-time for MessagePeerReaction.
|
|
var (
|
|
_ bin.Encoder = &MessagePeerReaction{}
|
|
_ bin.Decoder = &MessagePeerReaction{}
|
|
_ bin.BareEncoder = &MessagePeerReaction{}
|
|
_ bin.BareDecoder = &MessagePeerReaction{}
|
|
)
|
|
|
|
func (m *MessagePeerReaction) Zero() bool {
|
|
if m == nil {
|
|
return true
|
|
}
|
|
if !(m.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(m.Big == false) {
|
|
return false
|
|
}
|
|
if !(m.Unread == false) {
|
|
return false
|
|
}
|
|
if !(m.My == false) {
|
|
return false
|
|
}
|
|
if !(m.PeerID == nil) {
|
|
return false
|
|
}
|
|
if !(m.Date == 0) {
|
|
return false
|
|
}
|
|
if !(m.Reaction == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (m *MessagePeerReaction) String() string {
|
|
if m == nil {
|
|
return "MessagePeerReaction(nil)"
|
|
}
|
|
type Alias MessagePeerReaction
|
|
return fmt.Sprintf("MessagePeerReaction%+v", Alias(*m))
|
|
}
|
|
|
|
// FillFrom fills MessagePeerReaction from given interface.
|
|
func (m *MessagePeerReaction) FillFrom(from interface {
|
|
GetBig() (value bool)
|
|
GetUnread() (value bool)
|
|
GetMy() (value bool)
|
|
GetPeerID() (value PeerClass)
|
|
GetDate() (value int)
|
|
GetReaction() (value ReactionClass)
|
|
}) {
|
|
m.Big = from.GetBig()
|
|
m.Unread = from.GetUnread()
|
|
m.My = from.GetMy()
|
|
m.PeerID = from.GetPeerID()
|
|
m.Date = from.GetDate()
|
|
m.Reaction = from.GetReaction()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*MessagePeerReaction) TypeID() uint32 {
|
|
return MessagePeerReactionTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*MessagePeerReaction) TypeName() string {
|
|
return "messagePeerReaction"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (m *MessagePeerReaction) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "messagePeerReaction",
|
|
ID: MessagePeerReactionTypeID,
|
|
}
|
|
if m == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Big",
|
|
SchemaName: "big",
|
|
Null: !m.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Unread",
|
|
SchemaName: "unread",
|
|
Null: !m.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "My",
|
|
SchemaName: "my",
|
|
Null: !m.Flags.Has(2),
|
|
},
|
|
{
|
|
Name: "PeerID",
|
|
SchemaName: "peer_id",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "Reaction",
|
|
SchemaName: "reaction",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (m *MessagePeerReaction) SetFlags() {
|
|
if !(m.Big == false) {
|
|
m.Flags.Set(0)
|
|
}
|
|
if !(m.Unread == false) {
|
|
m.Flags.Set(1)
|
|
}
|
|
if !(m.My == false) {
|
|
m.Flags.Set(2)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (m *MessagePeerReaction) Encode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode messagePeerReaction#8c79b63c as nil")
|
|
}
|
|
b.PutID(MessagePeerReactionTypeID)
|
|
return m.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (m *MessagePeerReaction) EncodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode messagePeerReaction#8c79b63c as nil")
|
|
}
|
|
m.SetFlags()
|
|
if err := m.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field flags: %w", err)
|
|
}
|
|
if m.PeerID == nil {
|
|
return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field peer_id is nil")
|
|
}
|
|
if err := m.PeerID.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field peer_id: %w", err)
|
|
}
|
|
b.PutInt(m.Date)
|
|
if m.Reaction == nil {
|
|
return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field reaction is nil")
|
|
}
|
|
if err := m.Reaction.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field reaction: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (m *MessagePeerReaction) Decode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode messagePeerReaction#8c79b63c to nil")
|
|
}
|
|
if err := b.ConsumeID(MessagePeerReactionTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: %w", err)
|
|
}
|
|
return m.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (m *MessagePeerReaction) DecodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode messagePeerReaction#8c79b63c to nil")
|
|
}
|
|
{
|
|
if err := m.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field flags: %w", err)
|
|
}
|
|
}
|
|
m.Big = m.Flags.Has(0)
|
|
m.Unread = m.Flags.Has(1)
|
|
m.My = m.Flags.Has(2)
|
|
{
|
|
value, err := DecodePeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field peer_id: %w", err)
|
|
}
|
|
m.PeerID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field date: %w", err)
|
|
}
|
|
m.Date = value
|
|
}
|
|
{
|
|
value, err := DecodeReaction(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field reaction: %w", err)
|
|
}
|
|
m.Reaction = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetBig sets value of Big conditional field.
|
|
func (m *MessagePeerReaction) SetBig(value bool) {
|
|
if value {
|
|
m.Flags.Set(0)
|
|
m.Big = true
|
|
} else {
|
|
m.Flags.Unset(0)
|
|
m.Big = false
|
|
}
|
|
}
|
|
|
|
// GetBig returns value of Big conditional field.
|
|
func (m *MessagePeerReaction) GetBig() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(0)
|
|
}
|
|
|
|
// SetUnread sets value of Unread conditional field.
|
|
func (m *MessagePeerReaction) SetUnread(value bool) {
|
|
if value {
|
|
m.Flags.Set(1)
|
|
m.Unread = true
|
|
} else {
|
|
m.Flags.Unset(1)
|
|
m.Unread = false
|
|
}
|
|
}
|
|
|
|
// GetUnread returns value of Unread conditional field.
|
|
func (m *MessagePeerReaction) GetUnread() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(1)
|
|
}
|
|
|
|
// SetMy sets value of My conditional field.
|
|
func (m *MessagePeerReaction) SetMy(value bool) {
|
|
if value {
|
|
m.Flags.Set(2)
|
|
m.My = true
|
|
} else {
|
|
m.Flags.Unset(2)
|
|
m.My = false
|
|
}
|
|
}
|
|
|
|
// GetMy returns value of My conditional field.
|
|
func (m *MessagePeerReaction) GetMy() (value bool) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Flags.Has(2)
|
|
}
|
|
|
|
// GetPeerID returns value of PeerID field.
|
|
func (m *MessagePeerReaction) GetPeerID() (value PeerClass) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.PeerID
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (m *MessagePeerReaction) GetDate() (value int) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Date
|
|
}
|
|
|
|
// GetReaction returns value of Reaction field.
|
|
func (m *MessagePeerReaction) GetReaction() (value ReactionClass) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Reaction
|
|
}
|