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
228 lines
4.3 KiB
Go
228 lines
4.3 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package mt
|
|
|
|
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{}
|
|
)
|
|
|
|
// Message represents TL type `message#5bb8e511`.
|
|
type Message struct {
|
|
// MsgID field of Message.
|
|
MsgID int64
|
|
// Seqno field of Message.
|
|
Seqno int
|
|
// Bytes field of Message.
|
|
Bytes int
|
|
// Body field of Message.
|
|
Body GzipPacked
|
|
}
|
|
|
|
// MessageTypeID is TL type id of Message.
|
|
const MessageTypeID = 0x5bb8e511
|
|
|
|
// Ensuring interfaces in compile-time for Message.
|
|
var (
|
|
_ bin.Encoder = &Message{}
|
|
_ bin.Decoder = &Message{}
|
|
_ bin.BareEncoder = &Message{}
|
|
_ bin.BareDecoder = &Message{}
|
|
)
|
|
|
|
func (m *Message) Zero() bool {
|
|
if m == nil {
|
|
return true
|
|
}
|
|
if !(m.MsgID == 0) {
|
|
return false
|
|
}
|
|
if !(m.Seqno == 0) {
|
|
return false
|
|
}
|
|
if !(m.Bytes == 0) {
|
|
return false
|
|
}
|
|
if !(m.Body.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (m *Message) String() string {
|
|
if m == nil {
|
|
return "Message(nil)"
|
|
}
|
|
type Alias Message
|
|
return fmt.Sprintf("Message%+v", Alias(*m))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*Message) TypeID() uint32 {
|
|
return MessageTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*Message) TypeName() string {
|
|
return "message"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (m *Message) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "message",
|
|
ID: MessageTypeID,
|
|
}
|
|
if m == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "MsgID",
|
|
SchemaName: "msg_id",
|
|
},
|
|
{
|
|
Name: "Seqno",
|
|
SchemaName: "seqno",
|
|
},
|
|
{
|
|
Name: "Bytes",
|
|
SchemaName: "bytes",
|
|
},
|
|
{
|
|
Name: "Body",
|
|
SchemaName: "body",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (m *Message) Encode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode message#5bb8e511 as nil")
|
|
}
|
|
b.PutID(MessageTypeID)
|
|
return m.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (m *Message) EncodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't encode message#5bb8e511 as nil")
|
|
}
|
|
b.PutLong(m.MsgID)
|
|
b.PutInt(m.Seqno)
|
|
b.PutInt(m.Bytes)
|
|
if err := m.Body.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode message#5bb8e511: field body: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (m *Message) Decode(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode message#5bb8e511 to nil")
|
|
}
|
|
if err := b.ConsumeID(MessageTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode message#5bb8e511: %w", err)
|
|
}
|
|
return m.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (m *Message) DecodeBare(b *bin.Buffer) error {
|
|
if m == nil {
|
|
return fmt.Errorf("can't decode message#5bb8e511 to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode message#5bb8e511: field msg_id: %w", err)
|
|
}
|
|
m.MsgID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode message#5bb8e511: field seqno: %w", err)
|
|
}
|
|
m.Seqno = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode message#5bb8e511: field bytes: %w", err)
|
|
}
|
|
m.Bytes = value
|
|
}
|
|
{
|
|
if err := m.Body.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode message#5bb8e511: field body: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetMsgID returns value of MsgID field.
|
|
func (m *Message) GetMsgID() (value int64) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.MsgID
|
|
}
|
|
|
|
// GetSeqno returns value of Seqno field.
|
|
func (m *Message) GetSeqno() (value int) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Seqno
|
|
}
|
|
|
|
// GetBytes returns value of Bytes field.
|
|
func (m *Message) GetBytes() (value int) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Bytes
|
|
}
|
|
|
|
// GetBody returns value of Body field.
|
|
func (m *Message) GetBody() (value GzipPacked) {
|
|
if m == nil {
|
|
return
|
|
}
|
|
return m.Body
|
|
}
|