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

228 lines
5.1 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{}
)
// MessageImportInfo represents TL type `messageImportInfo#e6dfabcf`.
type MessageImportInfo struct {
// Name of the original sender
SenderName string
// Point in time (Unix timestamp) when the message was originally sent
Date int32
}
// MessageImportInfoTypeID is TL type id of MessageImportInfo.
const MessageImportInfoTypeID = 0xe6dfabcf
// Ensuring interfaces in compile-time for MessageImportInfo.
var (
_ bin.Encoder = &MessageImportInfo{}
_ bin.Decoder = &MessageImportInfo{}
_ bin.BareEncoder = &MessageImportInfo{}
_ bin.BareDecoder = &MessageImportInfo{}
)
func (m *MessageImportInfo) Zero() bool {
if m == nil {
return true
}
if !(m.SenderName == "") {
return false
}
if !(m.Date == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (m *MessageImportInfo) String() string {
if m == nil {
return "MessageImportInfo(nil)"
}
type Alias MessageImportInfo
return fmt.Sprintf("MessageImportInfo%+v", Alias(*m))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageImportInfo) TypeID() uint32 {
return MessageImportInfoTypeID
}
// TypeName returns name of type in TL schema.
func (*MessageImportInfo) TypeName() string {
return "messageImportInfo"
}
// TypeInfo returns info about TL type.
func (m *MessageImportInfo) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "messageImportInfo",
ID: MessageImportInfoTypeID,
}
if m == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "SenderName",
SchemaName: "sender_name",
},
{
Name: "Date",
SchemaName: "date",
},
}
return typ
}
// Encode implements bin.Encoder.
func (m *MessageImportInfo) Encode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode messageImportInfo#e6dfabcf as nil")
}
b.PutID(MessageImportInfoTypeID)
return m.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (m *MessageImportInfo) EncodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode messageImportInfo#e6dfabcf as nil")
}
b.PutString(m.SenderName)
b.PutInt32(m.Date)
return nil
}
// Decode implements bin.Decoder.
func (m *MessageImportInfo) Decode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode messageImportInfo#e6dfabcf to nil")
}
if err := b.ConsumeID(MessageImportInfoTypeID); err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: %w", err)
}
return m.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (m *MessageImportInfo) DecodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode messageImportInfo#e6dfabcf to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: field sender_name: %w", err)
}
m.SenderName = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: field date: %w", err)
}
m.Date = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (m *MessageImportInfo) EncodeTDLibJSON(b tdjson.Encoder) error {
if m == nil {
return fmt.Errorf("can't encode messageImportInfo#e6dfabcf as nil")
}
b.ObjStart()
b.PutID("messageImportInfo")
b.Comma()
b.FieldStart("sender_name")
b.PutString(m.SenderName)
b.Comma()
b.FieldStart("date")
b.PutInt32(m.Date)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (m *MessageImportInfo) DecodeTDLibJSON(b tdjson.Decoder) error {
if m == nil {
return fmt.Errorf("can't decode messageImportInfo#e6dfabcf to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("messageImportInfo"); err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: %w", err)
}
case "sender_name":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: field sender_name: %w", err)
}
m.SenderName = value
case "date":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode messageImportInfo#e6dfabcf: field date: %w", err)
}
m.Date = value
default:
return b.Skip()
}
return nil
})
}
// GetSenderName returns value of SenderName field.
func (m *MessageImportInfo) GetSenderName() (value string) {
if m == nil {
return
}
return m.SenderName
}
// GetDate returns value of Date field.
func (m *MessageImportInfo) GetDate() (value int32) {
if m == nil {
return
}
return m.Date
}