move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,407 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// HelpPremiumPromo represents TL type `help.premiumPromo#5334759c`.
|
||||
// Telegram Premium promotion information
|
||||
// Note that the video_sections+videos fields are a list of videos, and the corresponding
|
||||
// premium feature identifiers.
|
||||
// They're equivalent to a section => video dictionary, with keys from video_section and
|
||||
// values from videos.
|
||||
// The keys in video_sections correspond to a specific feature identifier, and the
|
||||
// associated promotional video should be shown when the associated feature row is
|
||||
// clicked.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/help.premiumPromo for reference.
|
||||
type HelpPremiumPromo struct {
|
||||
// Description of the current state of the user's Telegram Premium subscription
|
||||
StatusText string
|
||||
// Message entities for styled text¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/entities
|
||||
StatusEntities []MessageEntityClass
|
||||
// A list of premium feature identifiers »¹, associated to each video
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/premium
|
||||
VideoSections []string
|
||||
// A list of videos
|
||||
Videos []DocumentClass
|
||||
// Telegram Premium subscription options
|
||||
PeriodOptions []PremiumSubscriptionOption
|
||||
// Related user information
|
||||
Users []UserClass
|
||||
}
|
||||
|
||||
// HelpPremiumPromoTypeID is TL type id of HelpPremiumPromo.
|
||||
const HelpPremiumPromoTypeID = 0x5334759c
|
||||
|
||||
// Ensuring interfaces in compile-time for HelpPremiumPromo.
|
||||
var (
|
||||
_ bin.Encoder = &HelpPremiumPromo{}
|
||||
_ bin.Decoder = &HelpPremiumPromo{}
|
||||
_ bin.BareEncoder = &HelpPremiumPromo{}
|
||||
_ bin.BareDecoder = &HelpPremiumPromo{}
|
||||
)
|
||||
|
||||
func (p *HelpPremiumPromo) Zero() bool {
|
||||
if p == nil {
|
||||
return true
|
||||
}
|
||||
if !(p.StatusText == "") {
|
||||
return false
|
||||
}
|
||||
if !(p.StatusEntities == nil) {
|
||||
return false
|
||||
}
|
||||
if !(p.VideoSections == nil) {
|
||||
return false
|
||||
}
|
||||
if !(p.Videos == nil) {
|
||||
return false
|
||||
}
|
||||
if !(p.PeriodOptions == nil) {
|
||||
return false
|
||||
}
|
||||
if !(p.Users == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (p *HelpPremiumPromo) String() string {
|
||||
if p == nil {
|
||||
return "HelpPremiumPromo(nil)"
|
||||
}
|
||||
type Alias HelpPremiumPromo
|
||||
return fmt.Sprintf("HelpPremiumPromo%+v", Alias(*p))
|
||||
}
|
||||
|
||||
// FillFrom fills HelpPremiumPromo from given interface.
|
||||
func (p *HelpPremiumPromo) FillFrom(from interface {
|
||||
GetStatusText() (value string)
|
||||
GetStatusEntities() (value []MessageEntityClass)
|
||||
GetVideoSections() (value []string)
|
||||
GetVideos() (value []DocumentClass)
|
||||
GetPeriodOptions() (value []PremiumSubscriptionOption)
|
||||
GetUsers() (value []UserClass)
|
||||
}) {
|
||||
p.StatusText = from.GetStatusText()
|
||||
p.StatusEntities = from.GetStatusEntities()
|
||||
p.VideoSections = from.GetVideoSections()
|
||||
p.Videos = from.GetVideos()
|
||||
p.PeriodOptions = from.GetPeriodOptions()
|
||||
p.Users = from.GetUsers()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*HelpPremiumPromo) TypeID() uint32 {
|
||||
return HelpPremiumPromoTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*HelpPremiumPromo) TypeName() string {
|
||||
return "help.premiumPromo"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (p *HelpPremiumPromo) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "help.premiumPromo",
|
||||
ID: HelpPremiumPromoTypeID,
|
||||
}
|
||||
if p == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "StatusText",
|
||||
SchemaName: "status_text",
|
||||
},
|
||||
{
|
||||
Name: "StatusEntities",
|
||||
SchemaName: "status_entities",
|
||||
},
|
||||
{
|
||||
Name: "VideoSections",
|
||||
SchemaName: "video_sections",
|
||||
},
|
||||
{
|
||||
Name: "Videos",
|
||||
SchemaName: "videos",
|
||||
},
|
||||
{
|
||||
Name: "PeriodOptions",
|
||||
SchemaName: "period_options",
|
||||
},
|
||||
{
|
||||
Name: "Users",
|
||||
SchemaName: "users",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (p *HelpPremiumPromo) Encode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil")
|
||||
}
|
||||
b.PutID(HelpPremiumPromoTypeID)
|
||||
return p.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (p *HelpPremiumPromo) EncodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil")
|
||||
}
|
||||
b.PutString(p.StatusText)
|
||||
b.PutVectorHeader(len(p.StatusEntities))
|
||||
for idx, v := range p.StatusEntities {
|
||||
if v == nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d is nil", idx)
|
||||
}
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
b.PutVectorHeader(len(p.VideoSections))
|
||||
for _, v := range p.VideoSections {
|
||||
b.PutString(v)
|
||||
}
|
||||
b.PutVectorHeader(len(p.Videos))
|
||||
for idx, v := range p.Videos {
|
||||
if v == nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d is nil", idx)
|
||||
}
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
b.PutVectorHeader(len(p.PeriodOptions))
|
||||
for idx, v := range p.PeriodOptions {
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field period_options element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
b.PutVectorHeader(len(p.Users))
|
||||
for idx, v := range p.Users {
|
||||
if v == nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d is nil", idx)
|
||||
}
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (p *HelpPremiumPromo) Decode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil")
|
||||
}
|
||||
if err := b.ConsumeID(HelpPremiumPromoTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: %w", err)
|
||||
}
|
||||
return p.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (p *HelpPremiumPromo) DecodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_text: %w", err)
|
||||
}
|
||||
p.StatusText = value
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
p.StatusEntities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := DecodeMessageEntity(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", err)
|
||||
}
|
||||
p.StatusEntities = append(p.StatusEntities, value)
|
||||
}
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
p.VideoSections = make([]string, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", err)
|
||||
}
|
||||
p.VideoSections = append(p.VideoSections, value)
|
||||
}
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
p.Videos = make([]DocumentClass, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := DecodeDocument(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", err)
|
||||
}
|
||||
p.Videos = append(p.Videos, value)
|
||||
}
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
p.PeriodOptions = make([]PremiumSubscriptionOption, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value PremiumSubscriptionOption
|
||||
if err := value.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", err)
|
||||
}
|
||||
p.PeriodOptions = append(p.PeriodOptions, value)
|
||||
}
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
p.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := DecodeUser(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", err)
|
||||
}
|
||||
p.Users = append(p.Users, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetStatusText returns value of StatusText field.
|
||||
func (p *HelpPremiumPromo) GetStatusText() (value string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.StatusText
|
||||
}
|
||||
|
||||
// GetStatusEntities returns value of StatusEntities field.
|
||||
func (p *HelpPremiumPromo) GetStatusEntities() (value []MessageEntityClass) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.StatusEntities
|
||||
}
|
||||
|
||||
// GetVideoSections returns value of VideoSections field.
|
||||
func (p *HelpPremiumPromo) GetVideoSections() (value []string) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.VideoSections
|
||||
}
|
||||
|
||||
// GetVideos returns value of Videos field.
|
||||
func (p *HelpPremiumPromo) GetVideos() (value []DocumentClass) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.Videos
|
||||
}
|
||||
|
||||
// GetPeriodOptions returns value of PeriodOptions field.
|
||||
func (p *HelpPremiumPromo) GetPeriodOptions() (value []PremiumSubscriptionOption) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.PeriodOptions
|
||||
}
|
||||
|
||||
// GetUsers returns value of Users field.
|
||||
func (p *HelpPremiumPromo) GetUsers() (value []UserClass) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.Users
|
||||
}
|
||||
|
||||
// MapStatusEntities returns field StatusEntities wrapped in MessageEntityClassArray helper.
|
||||
func (p *HelpPremiumPromo) MapStatusEntities() (value MessageEntityClassArray) {
|
||||
return MessageEntityClassArray(p.StatusEntities)
|
||||
}
|
||||
|
||||
// MapVideos returns field Videos wrapped in DocumentClassArray helper.
|
||||
func (p *HelpPremiumPromo) MapVideos() (value DocumentClassArray) {
|
||||
return DocumentClassArray(p.Videos)
|
||||
}
|
||||
|
||||
// MapUsers returns field Users wrapped in UserClassArray helper.
|
||||
func (p *HelpPremiumPromo) MapUsers() (value UserClassArray) {
|
||||
return UserClassArray(p.Users)
|
||||
}
|
||||
Reference in New Issue
Block a user