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

330 lines
7.7 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{}
)
// ChatBoostSlot represents TL type `chatBoostSlot#757fac7`.
type ChatBoostSlot struct {
// Unique identifier of the slot
SlotID int32
// Identifier of the currently boosted chat; 0 if none
CurrentlyBoostedChatID int64
// Point in time (Unix timestamp) when the chat was boosted; 0 if none
StartDate int32
// Point in time (Unix timestamp) when the boost will expire
ExpirationDate int32
// Point in time (Unix timestamp) after which the boost can be used for another chat
CooldownUntilDate int32
}
// ChatBoostSlotTypeID is TL type id of ChatBoostSlot.
const ChatBoostSlotTypeID = 0x757fac7
// Ensuring interfaces in compile-time for ChatBoostSlot.
var (
_ bin.Encoder = &ChatBoostSlot{}
_ bin.Decoder = &ChatBoostSlot{}
_ bin.BareEncoder = &ChatBoostSlot{}
_ bin.BareDecoder = &ChatBoostSlot{}
)
func (c *ChatBoostSlot) Zero() bool {
if c == nil {
return true
}
if !(c.SlotID == 0) {
return false
}
if !(c.CurrentlyBoostedChatID == 0) {
return false
}
if !(c.StartDate == 0) {
return false
}
if !(c.ExpirationDate == 0) {
return false
}
if !(c.CooldownUntilDate == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatBoostSlot) String() string {
if c == nil {
return "ChatBoostSlot(nil)"
}
type Alias ChatBoostSlot
return fmt.Sprintf("ChatBoostSlot%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatBoostSlot) TypeID() uint32 {
return ChatBoostSlotTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatBoostSlot) TypeName() string {
return "chatBoostSlot"
}
// TypeInfo returns info about TL type.
func (c *ChatBoostSlot) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatBoostSlot",
ID: ChatBoostSlotTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "SlotID",
SchemaName: "slot_id",
},
{
Name: "CurrentlyBoostedChatID",
SchemaName: "currently_boosted_chat_id",
},
{
Name: "StartDate",
SchemaName: "start_date",
},
{
Name: "ExpirationDate",
SchemaName: "expiration_date",
},
{
Name: "CooldownUntilDate",
SchemaName: "cooldown_until_date",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatBoostSlot) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostSlot#757fac7 as nil")
}
b.PutID(ChatBoostSlotTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatBoostSlot) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostSlot#757fac7 as nil")
}
b.PutInt32(c.SlotID)
b.PutInt53(c.CurrentlyBoostedChatID)
b.PutInt32(c.StartDate)
b.PutInt32(c.ExpirationDate)
b.PutInt32(c.CooldownUntilDate)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatBoostSlot) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostSlot#757fac7 to nil")
}
if err := b.ConsumeID(ChatBoostSlotTypeID); err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatBoostSlot) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostSlot#757fac7 to nil")
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field slot_id: %w", err)
}
c.SlotID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field currently_boosted_chat_id: %w", err)
}
c.CurrentlyBoostedChatID = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field start_date: %w", err)
}
c.StartDate = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field expiration_date: %w", err)
}
c.ExpirationDate = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field cooldown_until_date: %w", err)
}
c.CooldownUntilDate = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatBoostSlot) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostSlot#757fac7 as nil")
}
b.ObjStart()
b.PutID("chatBoostSlot")
b.Comma()
b.FieldStart("slot_id")
b.PutInt32(c.SlotID)
b.Comma()
b.FieldStart("currently_boosted_chat_id")
b.PutInt53(c.CurrentlyBoostedChatID)
b.Comma()
b.FieldStart("start_date")
b.PutInt32(c.StartDate)
b.Comma()
b.FieldStart("expiration_date")
b.PutInt32(c.ExpirationDate)
b.Comma()
b.FieldStart("cooldown_until_date")
b.PutInt32(c.CooldownUntilDate)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatBoostSlot) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostSlot#757fac7 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("chatBoostSlot"); err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: %w", err)
}
case "slot_id":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field slot_id: %w", err)
}
c.SlotID = value
case "currently_boosted_chat_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field currently_boosted_chat_id: %w", err)
}
c.CurrentlyBoostedChatID = value
case "start_date":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field start_date: %w", err)
}
c.StartDate = value
case "expiration_date":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field expiration_date: %w", err)
}
c.ExpirationDate = value
case "cooldown_until_date":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatBoostSlot#757fac7: field cooldown_until_date: %w", err)
}
c.CooldownUntilDate = value
default:
return b.Skip()
}
return nil
})
}
// GetSlotID returns value of SlotID field.
func (c *ChatBoostSlot) GetSlotID() (value int32) {
if c == nil {
return
}
return c.SlotID
}
// GetCurrentlyBoostedChatID returns value of CurrentlyBoostedChatID field.
func (c *ChatBoostSlot) GetCurrentlyBoostedChatID() (value int64) {
if c == nil {
return
}
return c.CurrentlyBoostedChatID
}
// GetStartDate returns value of StartDate field.
func (c *ChatBoostSlot) GetStartDate() (value int32) {
if c == nil {
return
}
return c.StartDate
}
// GetExpirationDate returns value of ExpirationDate field.
func (c *ChatBoostSlot) GetExpirationDate() (value int32) {
if c == nil {
return
}
return c.ExpirationDate
}
// GetCooldownUntilDate returns value of CooldownUntilDate field.
func (c *ChatBoostSlot) GetCooldownUntilDate() (value int32) {
if c == nil {
return
}
return c.CooldownUntilDate
}