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
515 lines
13 KiB
Go
515 lines
13 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{}
|
|
)
|
|
|
|
// SponsoredMessage represents TL type `sponsoredMessage#b78d4c25`.
|
|
type SponsoredMessage struct {
|
|
// Message identifier; unique for the chat to which the sponsored message belongs among
|
|
// both ordinary and sponsored messages
|
|
MessageID int64
|
|
// True, if the message needs to be labeled as "recommended" instead of "sponsored"
|
|
IsRecommended bool
|
|
// True, if the message can be reported to Telegram moderators through
|
|
// reportChatSponsoredMessage
|
|
CanBeReported bool
|
|
// Content of the message. Currently, can be only of the types messageText,
|
|
// messageAnimation, messagePhoto, or messageVideo. Video messages can be viewed
|
|
// fullscreen
|
|
Content MessageContentClass
|
|
// Information about the sponsor of the message
|
|
Sponsor MessageSponsor
|
|
// Title of the sponsored message
|
|
Title string
|
|
// Text for the message action button
|
|
ButtonText string
|
|
// Identifier of the accent color for title, button text and message background
|
|
AccentColorID int32
|
|
// Identifier of a custom emoji to be shown on the message background; 0 if none
|
|
BackgroundCustomEmojiID int64
|
|
// If non-empty, additional information about the sponsored message to be shown along
|
|
// with the message
|
|
AdditionalInfo string
|
|
}
|
|
|
|
// SponsoredMessageTypeID is TL type id of SponsoredMessage.
|
|
const SponsoredMessageTypeID = 0xb78d4c25
|
|
|
|
// Ensuring interfaces in compile-time for SponsoredMessage.
|
|
var (
|
|
_ bin.Encoder = &SponsoredMessage{}
|
|
_ bin.Decoder = &SponsoredMessage{}
|
|
_ bin.BareEncoder = &SponsoredMessage{}
|
|
_ bin.BareDecoder = &SponsoredMessage{}
|
|
)
|
|
|
|
func (s *SponsoredMessage) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.MessageID == 0) {
|
|
return false
|
|
}
|
|
if !(s.IsRecommended == false) {
|
|
return false
|
|
}
|
|
if !(s.CanBeReported == false) {
|
|
return false
|
|
}
|
|
if !(s.Content == nil) {
|
|
return false
|
|
}
|
|
if !(s.Sponsor.Zero()) {
|
|
return false
|
|
}
|
|
if !(s.Title == "") {
|
|
return false
|
|
}
|
|
if !(s.ButtonText == "") {
|
|
return false
|
|
}
|
|
if !(s.AccentColorID == 0) {
|
|
return false
|
|
}
|
|
if !(s.BackgroundCustomEmojiID == 0) {
|
|
return false
|
|
}
|
|
if !(s.AdditionalInfo == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *SponsoredMessage) String() string {
|
|
if s == nil {
|
|
return "SponsoredMessage(nil)"
|
|
}
|
|
type Alias SponsoredMessage
|
|
return fmt.Sprintf("SponsoredMessage%+v", Alias(*s))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*SponsoredMessage) TypeID() uint32 {
|
|
return SponsoredMessageTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*SponsoredMessage) TypeName() string {
|
|
return "sponsoredMessage"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *SponsoredMessage) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "sponsoredMessage",
|
|
ID: SponsoredMessageTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "MessageID",
|
|
SchemaName: "message_id",
|
|
},
|
|
{
|
|
Name: "IsRecommended",
|
|
SchemaName: "is_recommended",
|
|
},
|
|
{
|
|
Name: "CanBeReported",
|
|
SchemaName: "can_be_reported",
|
|
},
|
|
{
|
|
Name: "Content",
|
|
SchemaName: "content",
|
|
},
|
|
{
|
|
Name: "Sponsor",
|
|
SchemaName: "sponsor",
|
|
},
|
|
{
|
|
Name: "Title",
|
|
SchemaName: "title",
|
|
},
|
|
{
|
|
Name: "ButtonText",
|
|
SchemaName: "button_text",
|
|
},
|
|
{
|
|
Name: "AccentColorID",
|
|
SchemaName: "accent_color_id",
|
|
},
|
|
{
|
|
Name: "BackgroundCustomEmojiID",
|
|
SchemaName: "background_custom_emoji_id",
|
|
},
|
|
{
|
|
Name: "AdditionalInfo",
|
|
SchemaName: "additional_info",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *SponsoredMessage) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode sponsoredMessage#b78d4c25 as nil")
|
|
}
|
|
b.PutID(SponsoredMessageTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *SponsoredMessage) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode sponsoredMessage#b78d4c25 as nil")
|
|
}
|
|
b.PutInt53(s.MessageID)
|
|
b.PutBool(s.IsRecommended)
|
|
b.PutBool(s.CanBeReported)
|
|
if s.Content == nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field content is nil")
|
|
}
|
|
if err := s.Content.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field content: %w", err)
|
|
}
|
|
if err := s.Sponsor.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field sponsor: %w", err)
|
|
}
|
|
b.PutString(s.Title)
|
|
b.PutString(s.ButtonText)
|
|
b.PutInt32(s.AccentColorID)
|
|
b.PutLong(s.BackgroundCustomEmojiID)
|
|
b.PutString(s.AdditionalInfo)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *SponsoredMessage) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode sponsoredMessage#b78d4c25 to nil")
|
|
}
|
|
if err := b.ConsumeID(SponsoredMessageTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *SponsoredMessage) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode sponsoredMessage#b78d4c25 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field message_id: %w", err)
|
|
}
|
|
s.MessageID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field is_recommended: %w", err)
|
|
}
|
|
s.IsRecommended = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field can_be_reported: %w", err)
|
|
}
|
|
s.CanBeReported = value
|
|
}
|
|
{
|
|
value, err := DecodeMessageContent(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field content: %w", err)
|
|
}
|
|
s.Content = value
|
|
}
|
|
{
|
|
if err := s.Sponsor.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field sponsor: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field title: %w", err)
|
|
}
|
|
s.Title = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field button_text: %w", err)
|
|
}
|
|
s.ButtonText = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field accent_color_id: %w", err)
|
|
}
|
|
s.AccentColorID = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field background_custom_emoji_id: %w", err)
|
|
}
|
|
s.BackgroundCustomEmojiID = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field additional_info: %w", err)
|
|
}
|
|
s.AdditionalInfo = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (s *SponsoredMessage) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode sponsoredMessage#b78d4c25 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("sponsoredMessage")
|
|
b.Comma()
|
|
b.FieldStart("message_id")
|
|
b.PutInt53(s.MessageID)
|
|
b.Comma()
|
|
b.FieldStart("is_recommended")
|
|
b.PutBool(s.IsRecommended)
|
|
b.Comma()
|
|
b.FieldStart("can_be_reported")
|
|
b.PutBool(s.CanBeReported)
|
|
b.Comma()
|
|
b.FieldStart("content")
|
|
if s.Content == nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field content is nil")
|
|
}
|
|
if err := s.Content.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field content: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("sponsor")
|
|
if err := s.Sponsor.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode sponsoredMessage#b78d4c25: field sponsor: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("title")
|
|
b.PutString(s.Title)
|
|
b.Comma()
|
|
b.FieldStart("button_text")
|
|
b.PutString(s.ButtonText)
|
|
b.Comma()
|
|
b.FieldStart("accent_color_id")
|
|
b.PutInt32(s.AccentColorID)
|
|
b.Comma()
|
|
b.FieldStart("background_custom_emoji_id")
|
|
b.PutLong(s.BackgroundCustomEmojiID)
|
|
b.Comma()
|
|
b.FieldStart("additional_info")
|
|
b.PutString(s.AdditionalInfo)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (s *SponsoredMessage) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode sponsoredMessage#b78d4c25 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("sponsoredMessage"); err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: %w", err)
|
|
}
|
|
case "message_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field message_id: %w", err)
|
|
}
|
|
s.MessageID = value
|
|
case "is_recommended":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field is_recommended: %w", err)
|
|
}
|
|
s.IsRecommended = value
|
|
case "can_be_reported":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field can_be_reported: %w", err)
|
|
}
|
|
s.CanBeReported = value
|
|
case "content":
|
|
value, err := DecodeTDLibJSONMessageContent(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field content: %w", err)
|
|
}
|
|
s.Content = value
|
|
case "sponsor":
|
|
if err := s.Sponsor.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field sponsor: %w", err)
|
|
}
|
|
case "title":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field title: %w", err)
|
|
}
|
|
s.Title = value
|
|
case "button_text":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field button_text: %w", err)
|
|
}
|
|
s.ButtonText = value
|
|
case "accent_color_id":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field accent_color_id: %w", err)
|
|
}
|
|
s.AccentColorID = value
|
|
case "background_custom_emoji_id":
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field background_custom_emoji_id: %w", err)
|
|
}
|
|
s.BackgroundCustomEmojiID = value
|
|
case "additional_info":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode sponsoredMessage#b78d4c25: field additional_info: %w", err)
|
|
}
|
|
s.AdditionalInfo = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetMessageID returns value of MessageID field.
|
|
func (s *SponsoredMessage) GetMessageID() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.MessageID
|
|
}
|
|
|
|
// GetIsRecommended returns value of IsRecommended field.
|
|
func (s *SponsoredMessage) GetIsRecommended() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.IsRecommended
|
|
}
|
|
|
|
// GetCanBeReported returns value of CanBeReported field.
|
|
func (s *SponsoredMessage) GetCanBeReported() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.CanBeReported
|
|
}
|
|
|
|
// GetContent returns value of Content field.
|
|
func (s *SponsoredMessage) GetContent() (value MessageContentClass) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Content
|
|
}
|
|
|
|
// GetSponsor returns value of Sponsor field.
|
|
func (s *SponsoredMessage) GetSponsor() (value MessageSponsor) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Sponsor
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (s *SponsoredMessage) GetTitle() (value string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Title
|
|
}
|
|
|
|
// GetButtonText returns value of ButtonText field.
|
|
func (s *SponsoredMessage) GetButtonText() (value string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.ButtonText
|
|
}
|
|
|
|
// GetAccentColorID returns value of AccentColorID field.
|
|
func (s *SponsoredMessage) GetAccentColorID() (value int32) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.AccentColorID
|
|
}
|
|
|
|
// GetBackgroundCustomEmojiID returns value of BackgroundCustomEmojiID field.
|
|
func (s *SponsoredMessage) GetBackgroundCustomEmojiID() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.BackgroundCustomEmojiID
|
|
}
|
|
|
|
// GetAdditionalInfo returns value of AdditionalInfo field.
|
|
func (s *SponsoredMessage) GetAdditionalInfo() (value string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.AdditionalInfo
|
|
}
|