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

262 lines
5.9 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{}
)
// BoostChatRequest represents TL type `boostChat#890ccd68`.
type BoostChatRequest struct {
// Identifier of the chat
ChatID int64
// Identifiers of boost slots of the current user from which to apply boosts to the chat
SlotIDs []int32
}
// BoostChatRequestTypeID is TL type id of BoostChatRequest.
const BoostChatRequestTypeID = 0x890ccd68
// Ensuring interfaces in compile-time for BoostChatRequest.
var (
_ bin.Encoder = &BoostChatRequest{}
_ bin.Decoder = &BoostChatRequest{}
_ bin.BareEncoder = &BoostChatRequest{}
_ bin.BareDecoder = &BoostChatRequest{}
)
func (b *BoostChatRequest) Zero() bool {
if b == nil {
return true
}
if !(b.ChatID == 0) {
return false
}
if !(b.SlotIDs == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *BoostChatRequest) String() string {
if b == nil {
return "BoostChatRequest(nil)"
}
type Alias BoostChatRequest
return fmt.Sprintf("BoostChatRequest%+v", Alias(*b))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BoostChatRequest) TypeID() uint32 {
return BoostChatRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*BoostChatRequest) TypeName() string {
return "boostChat"
}
// TypeInfo returns info about TL type.
func (b *BoostChatRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "boostChat",
ID: BoostChatRequestTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ChatID",
SchemaName: "chat_id",
},
{
Name: "SlotIDs",
SchemaName: "slot_ids",
},
}
return typ
}
// Encode implements bin.Encoder.
func (b *BoostChatRequest) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode boostChat#890ccd68 as nil")
}
buf.PutID(BoostChatRequestTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BoostChatRequest) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode boostChat#890ccd68 as nil")
}
buf.PutInt53(b.ChatID)
buf.PutInt(len(b.SlotIDs))
for _, v := range b.SlotIDs {
buf.PutInt32(v)
}
return nil
}
// Decode implements bin.Decoder.
func (b *BoostChatRequest) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode boostChat#890ccd68 to nil")
}
if err := buf.ConsumeID(BoostChatRequestTypeID); err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BoostChatRequest) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode boostChat#890ccd68 to nil")
}
{
value, err := buf.Int53()
if err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field chat_id: %w", err)
}
b.ChatID = value
}
{
headerLen, err := buf.Int()
if err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field slot_ids: %w", err)
}
if headerLen > 0 {
b.SlotIDs = make([]int32, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := buf.Int32()
if err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field slot_ids: %w", err)
}
b.SlotIDs = append(b.SlotIDs, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (b *BoostChatRequest) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil {
return fmt.Errorf("can't encode boostChat#890ccd68 as nil")
}
buf.ObjStart()
buf.PutID("boostChat")
buf.Comma()
buf.FieldStart("chat_id")
buf.PutInt53(b.ChatID)
buf.Comma()
buf.FieldStart("slot_ids")
buf.ArrStart()
for _, v := range b.SlotIDs {
buf.PutInt32(v)
buf.Comma()
}
buf.StripComma()
buf.ArrEnd()
buf.Comma()
buf.StripComma()
buf.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (b *BoostChatRequest) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("can't decode boostChat#890ccd68 to nil")
}
return buf.Obj(func(buf tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := buf.ConsumeID("boostChat"); err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: %w", err)
}
case "chat_id":
value, err := buf.Int53()
if err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field chat_id: %w", err)
}
b.ChatID = value
case "slot_ids":
if err := buf.Arr(func(buf tdjson.Decoder) error {
value, err := buf.Int32()
if err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field slot_ids: %w", err)
}
b.SlotIDs = append(b.SlotIDs, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode boostChat#890ccd68: field slot_ids: %w", err)
}
default:
return buf.Skip()
}
return nil
})
}
// GetChatID returns value of ChatID field.
func (b *BoostChatRequest) GetChatID() (value int64) {
if b == nil {
return
}
return b.ChatID
}
// GetSlotIDs returns value of SlotIDs field.
func (b *BoostChatRequest) GetSlotIDs() (value []int32) {
if b == nil {
return
}
return b.SlotIDs
}
// BoostChat invokes method boostChat#890ccd68 returning error if any.
func (c *Client) BoostChat(ctx context.Context, request *BoostChatRequest) (*ChatBoostSlots, error) {
var result ChatBoostSlots
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}