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

263 lines
6.8 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{}
)
// BanGroupCallParticipantsRequest represents TL type `banGroupCallParticipants#60890d03`.
type BanGroupCallParticipantsRequest struct {
// Group call identifier
GroupCallID int32
// Identifiers of group call participants to ban; identifiers of unknown users from the
// update updateGroupCallParticipants can be also passed to the method
UserIDs []int64
}
// BanGroupCallParticipantsRequestTypeID is TL type id of BanGroupCallParticipantsRequest.
const BanGroupCallParticipantsRequestTypeID = 0x60890d03
// Ensuring interfaces in compile-time for BanGroupCallParticipantsRequest.
var (
_ bin.Encoder = &BanGroupCallParticipantsRequest{}
_ bin.Decoder = &BanGroupCallParticipantsRequest{}
_ bin.BareEncoder = &BanGroupCallParticipantsRequest{}
_ bin.BareDecoder = &BanGroupCallParticipantsRequest{}
)
func (b *BanGroupCallParticipantsRequest) Zero() bool {
if b == nil {
return true
}
if !(b.GroupCallID == 0) {
return false
}
if !(b.UserIDs == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *BanGroupCallParticipantsRequest) String() string {
if b == nil {
return "BanGroupCallParticipantsRequest(nil)"
}
type Alias BanGroupCallParticipantsRequest
return fmt.Sprintf("BanGroupCallParticipantsRequest%+v", Alias(*b))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BanGroupCallParticipantsRequest) TypeID() uint32 {
return BanGroupCallParticipantsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*BanGroupCallParticipantsRequest) TypeName() string {
return "banGroupCallParticipants"
}
// TypeInfo returns info about TL type.
func (b *BanGroupCallParticipantsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "banGroupCallParticipants",
ID: BanGroupCallParticipantsRequestTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "GroupCallID",
SchemaName: "group_call_id",
},
{
Name: "UserIDs",
SchemaName: "user_ids",
},
}
return typ
}
// Encode implements bin.Encoder.
func (b *BanGroupCallParticipantsRequest) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode banGroupCallParticipants#60890d03 as nil")
}
buf.PutID(BanGroupCallParticipantsRequestTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BanGroupCallParticipantsRequest) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode banGroupCallParticipants#60890d03 as nil")
}
buf.PutInt32(b.GroupCallID)
buf.PutInt(len(b.UserIDs))
for _, v := range b.UserIDs {
buf.PutLong(v)
}
return nil
}
// Decode implements bin.Decoder.
func (b *BanGroupCallParticipantsRequest) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode banGroupCallParticipants#60890d03 to nil")
}
if err := buf.ConsumeID(BanGroupCallParticipantsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BanGroupCallParticipantsRequest) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode banGroupCallParticipants#60890d03 to nil")
}
{
value, err := buf.Int32()
if err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field group_call_id: %w", err)
}
b.GroupCallID = value
}
{
headerLen, err := buf.Int()
if err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field user_ids: %w", err)
}
if headerLen > 0 {
b.UserIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := buf.Long()
if err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field user_ids: %w", err)
}
b.UserIDs = append(b.UserIDs, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (b *BanGroupCallParticipantsRequest) EncodeTDLibJSON(buf tdjson.Encoder) error {
if b == nil {
return fmt.Errorf("can't encode banGroupCallParticipants#60890d03 as nil")
}
buf.ObjStart()
buf.PutID("banGroupCallParticipants")
buf.Comma()
buf.FieldStart("group_call_id")
buf.PutInt32(b.GroupCallID)
buf.Comma()
buf.FieldStart("user_ids")
buf.ArrStart()
for _, v := range b.UserIDs {
buf.PutLong(v)
buf.Comma()
}
buf.StripComma()
buf.ArrEnd()
buf.Comma()
buf.StripComma()
buf.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (b *BanGroupCallParticipantsRequest) DecodeTDLibJSON(buf tdjson.Decoder) error {
if b == nil {
return fmt.Errorf("can't decode banGroupCallParticipants#60890d03 to nil")
}
return buf.Obj(func(buf tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := buf.ConsumeID("banGroupCallParticipants"); err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: %w", err)
}
case "group_call_id":
value, err := buf.Int32()
if err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field group_call_id: %w", err)
}
b.GroupCallID = value
case "user_ids":
if err := buf.Arr(func(buf tdjson.Decoder) error {
value, err := buf.Long()
if err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field user_ids: %w", err)
}
b.UserIDs = append(b.UserIDs, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode banGroupCallParticipants#60890d03: field user_ids: %w", err)
}
default:
return buf.Skip()
}
return nil
})
}
// GetGroupCallID returns value of GroupCallID field.
func (b *BanGroupCallParticipantsRequest) GetGroupCallID() (value int32) {
if b == nil {
return
}
return b.GroupCallID
}
// GetUserIDs returns value of UserIDs field.
func (b *BanGroupCallParticipantsRequest) GetUserIDs() (value []int64) {
if b == nil {
return
}
return b.UserIDs
}
// BanGroupCallParticipants invokes method banGroupCallParticipants#60890d03 returning error if any.
func (c *Client) BanGroupCallParticipants(ctx context.Context, request *BanGroupCallParticipantsRequest) error {
var ok Ok
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}