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
398 lines
8.8 KiB
Go
398 lines
8.8 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{}
|
|
)
|
|
|
|
// ConnectedBotStarRef represents TL type `connectedBotStarRef#19a13f71`.
|
|
//
|
|
// See https://core.telegram.org/constructor/connectedBotStarRef for reference.
|
|
type ConnectedBotStarRef struct {
|
|
// Flags field of ConnectedBotStarRef.
|
|
Flags bin.Fields
|
|
// Revoked field of ConnectedBotStarRef.
|
|
Revoked bool
|
|
// URL field of ConnectedBotStarRef.
|
|
URL string
|
|
// Date field of ConnectedBotStarRef.
|
|
Date int
|
|
// BotID field of ConnectedBotStarRef.
|
|
BotID int64
|
|
// CommissionPermille field of ConnectedBotStarRef.
|
|
CommissionPermille int
|
|
// DurationMonths field of ConnectedBotStarRef.
|
|
//
|
|
// Use SetDurationMonths and GetDurationMonths helpers.
|
|
DurationMonths int
|
|
// Participants field of ConnectedBotStarRef.
|
|
Participants int64
|
|
// Revenue field of ConnectedBotStarRef.
|
|
Revenue int64
|
|
}
|
|
|
|
// ConnectedBotStarRefTypeID is TL type id of ConnectedBotStarRef.
|
|
const ConnectedBotStarRefTypeID = 0x19a13f71
|
|
|
|
// Ensuring interfaces in compile-time for ConnectedBotStarRef.
|
|
var (
|
|
_ bin.Encoder = &ConnectedBotStarRef{}
|
|
_ bin.Decoder = &ConnectedBotStarRef{}
|
|
_ bin.BareEncoder = &ConnectedBotStarRef{}
|
|
_ bin.BareDecoder = &ConnectedBotStarRef{}
|
|
)
|
|
|
|
func (c *ConnectedBotStarRef) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(c.Revoked == false) {
|
|
return false
|
|
}
|
|
if !(c.URL == "") {
|
|
return false
|
|
}
|
|
if !(c.Date == 0) {
|
|
return false
|
|
}
|
|
if !(c.BotID == 0) {
|
|
return false
|
|
}
|
|
if !(c.CommissionPermille == 0) {
|
|
return false
|
|
}
|
|
if !(c.DurationMonths == 0) {
|
|
return false
|
|
}
|
|
if !(c.Participants == 0) {
|
|
return false
|
|
}
|
|
if !(c.Revenue == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ConnectedBotStarRef) String() string {
|
|
if c == nil {
|
|
return "ConnectedBotStarRef(nil)"
|
|
}
|
|
type Alias ConnectedBotStarRef
|
|
return fmt.Sprintf("ConnectedBotStarRef%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills ConnectedBotStarRef from given interface.
|
|
func (c *ConnectedBotStarRef) FillFrom(from interface {
|
|
GetRevoked() (value bool)
|
|
GetURL() (value string)
|
|
GetDate() (value int)
|
|
GetBotID() (value int64)
|
|
GetCommissionPermille() (value int)
|
|
GetDurationMonths() (value int, ok bool)
|
|
GetParticipants() (value int64)
|
|
GetRevenue() (value int64)
|
|
}) {
|
|
c.Revoked = from.GetRevoked()
|
|
c.URL = from.GetURL()
|
|
c.Date = from.GetDate()
|
|
c.BotID = from.GetBotID()
|
|
c.CommissionPermille = from.GetCommissionPermille()
|
|
if val, ok := from.GetDurationMonths(); ok {
|
|
c.DurationMonths = val
|
|
}
|
|
|
|
c.Participants = from.GetParticipants()
|
|
c.Revenue = from.GetRevenue()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ConnectedBotStarRef) TypeID() uint32 {
|
|
return ConnectedBotStarRefTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ConnectedBotStarRef) TypeName() string {
|
|
return "connectedBotStarRef"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ConnectedBotStarRef) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "connectedBotStarRef",
|
|
ID: ConnectedBotStarRefTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Revoked",
|
|
SchemaName: "revoked",
|
|
Null: !c.Flags.Has(1),
|
|
},
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "BotID",
|
|
SchemaName: "bot_id",
|
|
},
|
|
{
|
|
Name: "CommissionPermille",
|
|
SchemaName: "commission_permille",
|
|
},
|
|
{
|
|
Name: "DurationMonths",
|
|
SchemaName: "duration_months",
|
|
Null: !c.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Participants",
|
|
SchemaName: "participants",
|
|
},
|
|
{
|
|
Name: "Revenue",
|
|
SchemaName: "revenue",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (c *ConnectedBotStarRef) SetFlags() {
|
|
if !(c.Revoked == false) {
|
|
c.Flags.Set(1)
|
|
}
|
|
if !(c.DurationMonths == 0) {
|
|
c.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ConnectedBotStarRef) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode connectedBotStarRef#19a13f71 as nil")
|
|
}
|
|
b.PutID(ConnectedBotStarRefTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ConnectedBotStarRef) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode connectedBotStarRef#19a13f71 as nil")
|
|
}
|
|
c.SetFlags()
|
|
if err := c.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode connectedBotStarRef#19a13f71: field flags: %w", err)
|
|
}
|
|
b.PutString(c.URL)
|
|
b.PutInt(c.Date)
|
|
b.PutLong(c.BotID)
|
|
b.PutInt(c.CommissionPermille)
|
|
if c.Flags.Has(0) {
|
|
b.PutInt(c.DurationMonths)
|
|
}
|
|
b.PutLong(c.Participants)
|
|
b.PutLong(c.Revenue)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ConnectedBotStarRef) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode connectedBotStarRef#19a13f71 to nil")
|
|
}
|
|
if err := b.ConsumeID(ConnectedBotStarRefTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ConnectedBotStarRef) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode connectedBotStarRef#19a13f71 to nil")
|
|
}
|
|
{
|
|
if err := c.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field flags: %w", err)
|
|
}
|
|
}
|
|
c.Revoked = c.Flags.Has(1)
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field url: %w", err)
|
|
}
|
|
c.URL = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field date: %w", err)
|
|
}
|
|
c.Date = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field bot_id: %w", err)
|
|
}
|
|
c.BotID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field commission_permille: %w", err)
|
|
}
|
|
c.CommissionPermille = value
|
|
}
|
|
if c.Flags.Has(0) {
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field duration_months: %w", err)
|
|
}
|
|
c.DurationMonths = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field participants: %w", err)
|
|
}
|
|
c.Participants = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode connectedBotStarRef#19a13f71: field revenue: %w", err)
|
|
}
|
|
c.Revenue = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetRevoked sets value of Revoked conditional field.
|
|
func (c *ConnectedBotStarRef) SetRevoked(value bool) {
|
|
if value {
|
|
c.Flags.Set(1)
|
|
c.Revoked = true
|
|
} else {
|
|
c.Flags.Unset(1)
|
|
c.Revoked = false
|
|
}
|
|
}
|
|
|
|
// GetRevoked returns value of Revoked conditional field.
|
|
func (c *ConnectedBotStarRef) GetRevoked() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Flags.Has(1)
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (c *ConnectedBotStarRef) GetURL() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.URL
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (c *ConnectedBotStarRef) GetDate() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Date
|
|
}
|
|
|
|
// GetBotID returns value of BotID field.
|
|
func (c *ConnectedBotStarRef) GetBotID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.BotID
|
|
}
|
|
|
|
// GetCommissionPermille returns value of CommissionPermille field.
|
|
func (c *ConnectedBotStarRef) GetCommissionPermille() (value int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.CommissionPermille
|
|
}
|
|
|
|
// SetDurationMonths sets value of DurationMonths conditional field.
|
|
func (c *ConnectedBotStarRef) SetDurationMonths(value int) {
|
|
c.Flags.Set(0)
|
|
c.DurationMonths = value
|
|
}
|
|
|
|
// GetDurationMonths returns value of DurationMonths conditional field and
|
|
// boolean which is true if field was set.
|
|
func (c *ConnectedBotStarRef) GetDurationMonths() (value int, ok bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
if !c.Flags.Has(0) {
|
|
return value, false
|
|
}
|
|
return c.DurationMonths, true
|
|
}
|
|
|
|
// GetParticipants returns value of Participants field.
|
|
func (c *ConnectedBotStarRef) GetParticipants() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Participants
|
|
}
|
|
|
|
// GetRevenue returns value of Revenue field.
|
|
func (c *ConnectedBotStarRef) GetRevenue() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Revenue
|
|
}
|