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

200 lines
5.0 KiB
Go

// 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{}
)
// StatsMessageStats represents TL type `stats.messageStats#7fe91c14`.
// Message statistics
//
// See https://core.telegram.org/constructor/stats.messageStats for reference.
type StatsMessageStats struct {
// Message view graph
ViewsGraph StatsGraphClass
// A graph containing the number of reactions on stories categorized by emotion
ReactionsByEmotionGraph StatsGraphClass
}
// StatsMessageStatsTypeID is TL type id of StatsMessageStats.
const StatsMessageStatsTypeID = 0x7fe91c14
// Ensuring interfaces in compile-time for StatsMessageStats.
var (
_ bin.Encoder = &StatsMessageStats{}
_ bin.Decoder = &StatsMessageStats{}
_ bin.BareEncoder = &StatsMessageStats{}
_ bin.BareDecoder = &StatsMessageStats{}
)
func (m *StatsMessageStats) Zero() bool {
if m == nil {
return true
}
if !(m.ViewsGraph == nil) {
return false
}
if !(m.ReactionsByEmotionGraph == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (m *StatsMessageStats) String() string {
if m == nil {
return "StatsMessageStats(nil)"
}
type Alias StatsMessageStats
return fmt.Sprintf("StatsMessageStats%+v", Alias(*m))
}
// FillFrom fills StatsMessageStats from given interface.
func (m *StatsMessageStats) FillFrom(from interface {
GetViewsGraph() (value StatsGraphClass)
GetReactionsByEmotionGraph() (value StatsGraphClass)
}) {
m.ViewsGraph = from.GetViewsGraph()
m.ReactionsByEmotionGraph = from.GetReactionsByEmotionGraph()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StatsMessageStats) TypeID() uint32 {
return StatsMessageStatsTypeID
}
// TypeName returns name of type in TL schema.
func (*StatsMessageStats) TypeName() string {
return "stats.messageStats"
}
// TypeInfo returns info about TL type.
func (m *StatsMessageStats) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "stats.messageStats",
ID: StatsMessageStatsTypeID,
}
if m == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ViewsGraph",
SchemaName: "views_graph",
},
{
Name: "ReactionsByEmotionGraph",
SchemaName: "reactions_by_emotion_graph",
},
}
return typ
}
// Encode implements bin.Encoder.
func (m *StatsMessageStats) Encode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode stats.messageStats#7fe91c14 as nil")
}
b.PutID(StatsMessageStatsTypeID)
return m.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (m *StatsMessageStats) EncodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode stats.messageStats#7fe91c14 as nil")
}
if m.ViewsGraph == nil {
return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field views_graph is nil")
}
if err := m.ViewsGraph.Encode(b); err != nil {
return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field views_graph: %w", err)
}
if m.ReactionsByEmotionGraph == nil {
return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field reactions_by_emotion_graph is nil")
}
if err := m.ReactionsByEmotionGraph.Encode(b); err != nil {
return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field reactions_by_emotion_graph: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (m *StatsMessageStats) Decode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode stats.messageStats#7fe91c14 to nil")
}
if err := b.ConsumeID(StatsMessageStatsTypeID); err != nil {
return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: %w", err)
}
return m.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (m *StatsMessageStats) DecodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode stats.messageStats#7fe91c14 to nil")
}
{
value, err := DecodeStatsGraph(b)
if err != nil {
return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: field views_graph: %w", err)
}
m.ViewsGraph = value
}
{
value, err := DecodeStatsGraph(b)
if err != nil {
return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: field reactions_by_emotion_graph: %w", err)
}
m.ReactionsByEmotionGraph = value
}
return nil
}
// GetViewsGraph returns value of ViewsGraph field.
func (m *StatsMessageStats) GetViewsGraph() (value StatsGraphClass) {
if m == nil {
return
}
return m.ViewsGraph
}
// GetReactionsByEmotionGraph returns value of ReactionsByEmotionGraph field.
func (m *StatsMessageStats) GetReactionsByEmotionGraph() (value StatsGraphClass) {
if m == nil {
return
}
return m.ReactionsByEmotionGraph
}