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
220 lines
4.9 KiB
Go
Generated
220 lines
4.9 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{}
|
|
)
|
|
|
|
// StatsGroupTopPoster represents TL type `statsGroupTopPoster#9d04af9b`.
|
|
// Information about an active user in a supergroup
|
|
//
|
|
// See https://core.telegram.org/constructor/statsGroupTopPoster for reference.
|
|
type StatsGroupTopPoster struct {
|
|
// User ID
|
|
UserID int64
|
|
// Number of messages for statistics¹ period in consideration
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/stats
|
|
Messages int
|
|
// Average number of characters per message
|
|
AvgChars int
|
|
}
|
|
|
|
// StatsGroupTopPosterTypeID is TL type id of StatsGroupTopPoster.
|
|
const StatsGroupTopPosterTypeID = 0x9d04af9b
|
|
|
|
// Ensuring interfaces in compile-time for StatsGroupTopPoster.
|
|
var (
|
|
_ bin.Encoder = &StatsGroupTopPoster{}
|
|
_ bin.Decoder = &StatsGroupTopPoster{}
|
|
_ bin.BareEncoder = &StatsGroupTopPoster{}
|
|
_ bin.BareDecoder = &StatsGroupTopPoster{}
|
|
)
|
|
|
|
func (s *StatsGroupTopPoster) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(s.Messages == 0) {
|
|
return false
|
|
}
|
|
if !(s.AvgChars == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *StatsGroupTopPoster) String() string {
|
|
if s == nil {
|
|
return "StatsGroupTopPoster(nil)"
|
|
}
|
|
type Alias StatsGroupTopPoster
|
|
return fmt.Sprintf("StatsGroupTopPoster%+v", Alias(*s))
|
|
}
|
|
|
|
// FillFrom fills StatsGroupTopPoster from given interface.
|
|
func (s *StatsGroupTopPoster) FillFrom(from interface {
|
|
GetUserID() (value int64)
|
|
GetMessages() (value int)
|
|
GetAvgChars() (value int)
|
|
}) {
|
|
s.UserID = from.GetUserID()
|
|
s.Messages = from.GetMessages()
|
|
s.AvgChars = from.GetAvgChars()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StatsGroupTopPoster) TypeID() uint32 {
|
|
return StatsGroupTopPosterTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StatsGroupTopPoster) TypeName() string {
|
|
return "statsGroupTopPoster"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *StatsGroupTopPoster) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "statsGroupTopPoster",
|
|
ID: StatsGroupTopPosterTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "Messages",
|
|
SchemaName: "messages",
|
|
},
|
|
{
|
|
Name: "AvgChars",
|
|
SchemaName: "avg_chars",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *StatsGroupTopPoster) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode statsGroupTopPoster#9d04af9b as nil")
|
|
}
|
|
b.PutID(StatsGroupTopPosterTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *StatsGroupTopPoster) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode statsGroupTopPoster#9d04af9b as nil")
|
|
}
|
|
b.PutLong(s.UserID)
|
|
b.PutInt(s.Messages)
|
|
b.PutInt(s.AvgChars)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *StatsGroupTopPoster) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode statsGroupTopPoster#9d04af9b to nil")
|
|
}
|
|
if err := b.ConsumeID(StatsGroupTopPosterTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *StatsGroupTopPoster) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode statsGroupTopPoster#9d04af9b to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field user_id: %w", err)
|
|
}
|
|
s.UserID = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field messages: %w", err)
|
|
}
|
|
s.Messages = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode statsGroupTopPoster#9d04af9b: field avg_chars: %w", err)
|
|
}
|
|
s.AvgChars = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (s *StatsGroupTopPoster) GetUserID() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.UserID
|
|
}
|
|
|
|
// GetMessages returns value of Messages field.
|
|
func (s *StatsGroupTopPoster) GetMessages() (value int) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Messages
|
|
}
|
|
|
|
// GetAvgChars returns value of AvgChars field.
|
|
func (s *StatsGroupTopPoster) GetAvgChars() (value int) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.AvgChars
|
|
}
|