- 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
249 lines
6.0 KiB
Go
249 lines
6.0 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{}
|
|
)
|
|
|
|
// StarsGiveawayWinnersOption represents TL type `starsGiveawayWinnersOption#54236209`.
|
|
// Allowed options for the number of giveaway winners.
|
|
//
|
|
// See https://core.telegram.org/constructor/starsGiveawayWinnersOption for reference.
|
|
type StarsGiveawayWinnersOption struct {
|
|
// Flags, see TL conditional fields¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
|
Flags bin.Fields
|
|
// If set, this option must be pre-selected by default in the option list.
|
|
Default bool
|
|
// The number of users that will be randomly chosen as winners.
|
|
Users int
|
|
// The number of Telegram Stars¹ each winner will receive.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/stars
|
|
PerUserStars int64
|
|
}
|
|
|
|
// StarsGiveawayWinnersOptionTypeID is TL type id of StarsGiveawayWinnersOption.
|
|
const StarsGiveawayWinnersOptionTypeID = 0x54236209
|
|
|
|
// Ensuring interfaces in compile-time for StarsGiveawayWinnersOption.
|
|
var (
|
|
_ bin.Encoder = &StarsGiveawayWinnersOption{}
|
|
_ bin.Decoder = &StarsGiveawayWinnersOption{}
|
|
_ bin.BareEncoder = &StarsGiveawayWinnersOption{}
|
|
_ bin.BareDecoder = &StarsGiveawayWinnersOption{}
|
|
)
|
|
|
|
func (s *StarsGiveawayWinnersOption) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.Flags.Zero()) {
|
|
return false
|
|
}
|
|
if !(s.Default == false) {
|
|
return false
|
|
}
|
|
if !(s.Users == 0) {
|
|
return false
|
|
}
|
|
if !(s.PerUserStars == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *StarsGiveawayWinnersOption) String() string {
|
|
if s == nil {
|
|
return "StarsGiveawayWinnersOption(nil)"
|
|
}
|
|
type Alias StarsGiveawayWinnersOption
|
|
return fmt.Sprintf("StarsGiveawayWinnersOption%+v", Alias(*s))
|
|
}
|
|
|
|
// FillFrom fills StarsGiveawayWinnersOption from given interface.
|
|
func (s *StarsGiveawayWinnersOption) FillFrom(from interface {
|
|
GetDefault() (value bool)
|
|
GetUsers() (value int)
|
|
GetPerUserStars() (value int64)
|
|
}) {
|
|
s.Default = from.GetDefault()
|
|
s.Users = from.GetUsers()
|
|
s.PerUserStars = from.GetPerUserStars()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StarsGiveawayWinnersOption) TypeID() uint32 {
|
|
return StarsGiveawayWinnersOptionTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StarsGiveawayWinnersOption) TypeName() string {
|
|
return "starsGiveawayWinnersOption"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *StarsGiveawayWinnersOption) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "starsGiveawayWinnersOption",
|
|
ID: StarsGiveawayWinnersOptionTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Default",
|
|
SchemaName: "default",
|
|
Null: !s.Flags.Has(0),
|
|
},
|
|
{
|
|
Name: "Users",
|
|
SchemaName: "users",
|
|
},
|
|
{
|
|
Name: "PerUserStars",
|
|
SchemaName: "per_user_stars",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// SetFlags sets flags for non-zero fields.
|
|
func (s *StarsGiveawayWinnersOption) SetFlags() {
|
|
if !(s.Default == false) {
|
|
s.Flags.Set(0)
|
|
}
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *StarsGiveawayWinnersOption) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starsGiveawayWinnersOption#54236209 as nil")
|
|
}
|
|
b.PutID(StarsGiveawayWinnersOptionTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *StarsGiveawayWinnersOption) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starsGiveawayWinnersOption#54236209 as nil")
|
|
}
|
|
s.SetFlags()
|
|
if err := s.Flags.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode starsGiveawayWinnersOption#54236209: field flags: %w", err)
|
|
}
|
|
b.PutInt(s.Users)
|
|
b.PutLong(s.PerUserStars)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *StarsGiveawayWinnersOption) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starsGiveawayWinnersOption#54236209 to nil")
|
|
}
|
|
if err := b.ConsumeID(StarsGiveawayWinnersOptionTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *StarsGiveawayWinnersOption) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starsGiveawayWinnersOption#54236209 to nil")
|
|
}
|
|
{
|
|
if err := s.Flags.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field flags: %w", err)
|
|
}
|
|
}
|
|
s.Default = s.Flags.Has(0)
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field users: %w", err)
|
|
}
|
|
s.Users = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starsGiveawayWinnersOption#54236209: field per_user_stars: %w", err)
|
|
}
|
|
s.PerUserStars = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SetDefault sets value of Default conditional field.
|
|
func (s *StarsGiveawayWinnersOption) SetDefault(value bool) {
|
|
if value {
|
|
s.Flags.Set(0)
|
|
s.Default = true
|
|
} else {
|
|
s.Flags.Unset(0)
|
|
s.Default = false
|
|
}
|
|
}
|
|
|
|
// GetDefault returns value of Default conditional field.
|
|
func (s *StarsGiveawayWinnersOption) GetDefault() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Flags.Has(0)
|
|
}
|
|
|
|
// GetUsers returns value of Users field.
|
|
func (s *StarsGiveawayWinnersOption) GetUsers() (value int) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Users
|
|
}
|
|
|
|
// GetPerUserStars returns value of PerUserStars field.
|
|
func (s *StarsGiveawayWinnersOption) GetPerUserStars() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.PerUserStars
|
|
}
|