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
363 lines
9.1 KiB
Go
Generated
363 lines
9.1 KiB
Go
Generated
// 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{}
|
|
)
|
|
|
|
// PhoneGroupParticipants represents TL type `phone.groupParticipants#f47751b6`.
|
|
// Info about the participants of a group call or livestream
|
|
//
|
|
// See https://core.telegram.org/constructor/phone.groupParticipants for reference.
|
|
type PhoneGroupParticipants struct {
|
|
// Number of participants
|
|
Count int
|
|
// List of participants
|
|
Participants []GroupCallParticipant
|
|
// If not empty, the specified list of participants is partial, and more participants can
|
|
// be fetched specifying this parameter as offset in phone.getGroupParticipants¹.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/method/phone.getGroupParticipants
|
|
NextOffset string
|
|
// Mentioned chats
|
|
Chats []ChatClass
|
|
// Mentioned users
|
|
Users []UserClass
|
|
// Version info
|
|
Version int
|
|
}
|
|
|
|
// PhoneGroupParticipantsTypeID is TL type id of PhoneGroupParticipants.
|
|
const PhoneGroupParticipantsTypeID = 0xf47751b6
|
|
|
|
// Ensuring interfaces in compile-time for PhoneGroupParticipants.
|
|
var (
|
|
_ bin.Encoder = &PhoneGroupParticipants{}
|
|
_ bin.Decoder = &PhoneGroupParticipants{}
|
|
_ bin.BareEncoder = &PhoneGroupParticipants{}
|
|
_ bin.BareDecoder = &PhoneGroupParticipants{}
|
|
)
|
|
|
|
func (g *PhoneGroupParticipants) Zero() bool {
|
|
if g == nil {
|
|
return true
|
|
}
|
|
if !(g.Count == 0) {
|
|
return false
|
|
}
|
|
if !(g.Participants == nil) {
|
|
return false
|
|
}
|
|
if !(g.NextOffset == "") {
|
|
return false
|
|
}
|
|
if !(g.Chats == nil) {
|
|
return false
|
|
}
|
|
if !(g.Users == nil) {
|
|
return false
|
|
}
|
|
if !(g.Version == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (g *PhoneGroupParticipants) String() string {
|
|
if g == nil {
|
|
return "PhoneGroupParticipants(nil)"
|
|
}
|
|
type Alias PhoneGroupParticipants
|
|
return fmt.Sprintf("PhoneGroupParticipants%+v", Alias(*g))
|
|
}
|
|
|
|
// FillFrom fills PhoneGroupParticipants from given interface.
|
|
func (g *PhoneGroupParticipants) FillFrom(from interface {
|
|
GetCount() (value int)
|
|
GetParticipants() (value []GroupCallParticipant)
|
|
GetNextOffset() (value string)
|
|
GetChats() (value []ChatClass)
|
|
GetUsers() (value []UserClass)
|
|
GetVersion() (value int)
|
|
}) {
|
|
g.Count = from.GetCount()
|
|
g.Participants = from.GetParticipants()
|
|
g.NextOffset = from.GetNextOffset()
|
|
g.Chats = from.GetChats()
|
|
g.Users = from.GetUsers()
|
|
g.Version = from.GetVersion()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PhoneGroupParticipants) TypeID() uint32 {
|
|
return PhoneGroupParticipantsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PhoneGroupParticipants) TypeName() string {
|
|
return "phone.groupParticipants"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (g *PhoneGroupParticipants) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "phone.groupParticipants",
|
|
ID: PhoneGroupParticipantsTypeID,
|
|
}
|
|
if g == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Count",
|
|
SchemaName: "count",
|
|
},
|
|
{
|
|
Name: "Participants",
|
|
SchemaName: "participants",
|
|
},
|
|
{
|
|
Name: "NextOffset",
|
|
SchemaName: "next_offset",
|
|
},
|
|
{
|
|
Name: "Chats",
|
|
SchemaName: "chats",
|
|
},
|
|
{
|
|
Name: "Users",
|
|
SchemaName: "users",
|
|
},
|
|
{
|
|
Name: "Version",
|
|
SchemaName: "version",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (g *PhoneGroupParticipants) Encode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode phone.groupParticipants#f47751b6 as nil")
|
|
}
|
|
b.PutID(PhoneGroupParticipantsTypeID)
|
|
return g.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (g *PhoneGroupParticipants) EncodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't encode phone.groupParticipants#f47751b6 as nil")
|
|
}
|
|
b.PutInt(g.Count)
|
|
b.PutVectorHeader(len(g.Participants))
|
|
for idx, v := range g.Participants {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode phone.groupParticipants#f47751b6: field participants element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
b.PutString(g.NextOffset)
|
|
b.PutVectorHeader(len(g.Chats))
|
|
for idx, v := range g.Chats {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode phone.groupParticipants#f47751b6: field chats element with index %d is nil", idx)
|
|
}
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode phone.groupParticipants#f47751b6: field chats element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
b.PutVectorHeader(len(g.Users))
|
|
for idx, v := range g.Users {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode phone.groupParticipants#f47751b6: field users element with index %d is nil", idx)
|
|
}
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode phone.groupParticipants#f47751b6: field users element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
b.PutInt(g.Version)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (g *PhoneGroupParticipants) Decode(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode phone.groupParticipants#f47751b6 to nil")
|
|
}
|
|
if err := b.ConsumeID(PhoneGroupParticipantsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: %w", err)
|
|
}
|
|
return g.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (g *PhoneGroupParticipants) DecodeBare(b *bin.Buffer) error {
|
|
if g == nil {
|
|
return fmt.Errorf("can't decode phone.groupParticipants#f47751b6 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field count: %w", err)
|
|
}
|
|
g.Count = value
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field participants: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
g.Participants = make([]GroupCallParticipant, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value GroupCallParticipant
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field participants: %w", err)
|
|
}
|
|
g.Participants = append(g.Participants, value)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field next_offset: %w", err)
|
|
}
|
|
g.NextOffset = value
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field chats: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
g.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodeChat(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field chats: %w", err)
|
|
}
|
|
g.Chats = append(g.Chats, value)
|
|
}
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field users: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
g.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodeUser(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field users: %w", err)
|
|
}
|
|
g.Users = append(g.Users, value)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field version: %w", err)
|
|
}
|
|
g.Version = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetCount returns value of Count field.
|
|
func (g *PhoneGroupParticipants) GetCount() (value int) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Count
|
|
}
|
|
|
|
// GetParticipants returns value of Participants field.
|
|
func (g *PhoneGroupParticipants) GetParticipants() (value []GroupCallParticipant) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Participants
|
|
}
|
|
|
|
// GetNextOffset returns value of NextOffset field.
|
|
func (g *PhoneGroupParticipants) GetNextOffset() (value string) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.NextOffset
|
|
}
|
|
|
|
// GetChats returns value of Chats field.
|
|
func (g *PhoneGroupParticipants) GetChats() (value []ChatClass) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Chats
|
|
}
|
|
|
|
// GetUsers returns value of Users field.
|
|
func (g *PhoneGroupParticipants) GetUsers() (value []UserClass) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Users
|
|
}
|
|
|
|
// GetVersion returns value of Version field.
|
|
func (g *PhoneGroupParticipants) GetVersion() (value int) {
|
|
if g == nil {
|
|
return
|
|
}
|
|
return g.Version
|
|
}
|
|
|
|
// MapChats returns field Chats wrapped in ChatClassArray helper.
|
|
func (g *PhoneGroupParticipants) MapChats() (value ChatClassArray) {
|
|
return ChatClassArray(g.Chats)
|
|
}
|
|
|
|
// MapUsers returns field Users wrapped in UserClassArray helper.
|
|
func (g *PhoneGroupParticipants) MapUsers() (value UserClassArray) {
|
|
return UserClassArray(g.Users)
|
|
}
|