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

306 lines
8.1 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{}
)
// ChatStatisticsInteractionInfo represents TL type `chatStatisticsInteractionInfo#694a9a8d`.
type ChatStatisticsInteractionInfo struct {
// Type of the object
ObjectType ChatStatisticsObjectTypeClass
// Number of times the object was viewed
ViewCount int32
// Number of times the object was forwarded
ForwardCount int32
// Number of times reactions were added to the object
ReactionCount int32
}
// ChatStatisticsInteractionInfoTypeID is TL type id of ChatStatisticsInteractionInfo.
const ChatStatisticsInteractionInfoTypeID = 0x694a9a8d
// Ensuring interfaces in compile-time for ChatStatisticsInteractionInfo.
var (
_ bin.Encoder = &ChatStatisticsInteractionInfo{}
_ bin.Decoder = &ChatStatisticsInteractionInfo{}
_ bin.BareEncoder = &ChatStatisticsInteractionInfo{}
_ bin.BareDecoder = &ChatStatisticsInteractionInfo{}
)
func (c *ChatStatisticsInteractionInfo) Zero() bool {
if c == nil {
return true
}
if !(c.ObjectType == nil) {
return false
}
if !(c.ViewCount == 0) {
return false
}
if !(c.ForwardCount == 0) {
return false
}
if !(c.ReactionCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatStatisticsInteractionInfo) String() string {
if c == nil {
return "ChatStatisticsInteractionInfo(nil)"
}
type Alias ChatStatisticsInteractionInfo
return fmt.Sprintf("ChatStatisticsInteractionInfo%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatStatisticsInteractionInfo) TypeID() uint32 {
return ChatStatisticsInteractionInfoTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatStatisticsInteractionInfo) TypeName() string {
return "chatStatisticsInteractionInfo"
}
// TypeInfo returns info about TL type.
func (c *ChatStatisticsInteractionInfo) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatStatisticsInteractionInfo",
ID: ChatStatisticsInteractionInfoTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ObjectType",
SchemaName: "object_type",
},
{
Name: "ViewCount",
SchemaName: "view_count",
},
{
Name: "ForwardCount",
SchemaName: "forward_count",
},
{
Name: "ReactionCount",
SchemaName: "reaction_count",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatStatisticsInteractionInfo) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatStatisticsInteractionInfo#694a9a8d as nil")
}
b.PutID(ChatStatisticsInteractionInfoTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatStatisticsInteractionInfo) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatStatisticsInteractionInfo#694a9a8d as nil")
}
if c.ObjectType == nil {
return fmt.Errorf("unable to encode chatStatisticsInteractionInfo#694a9a8d: field object_type is nil")
}
if err := c.ObjectType.Encode(b); err != nil {
return fmt.Errorf("unable to encode chatStatisticsInteractionInfo#694a9a8d: field object_type: %w", err)
}
b.PutInt32(c.ViewCount)
b.PutInt32(c.ForwardCount)
b.PutInt32(c.ReactionCount)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatStatisticsInteractionInfo) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatStatisticsInteractionInfo#694a9a8d to nil")
}
if err := b.ConsumeID(ChatStatisticsInteractionInfoTypeID); err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatStatisticsInteractionInfo) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatStatisticsInteractionInfo#694a9a8d to nil")
}
{
value, err := DecodeChatStatisticsObjectType(b)
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field object_type: %w", err)
}
c.ObjectType = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field view_count: %w", err)
}
c.ViewCount = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field forward_count: %w", err)
}
c.ForwardCount = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field reaction_count: %w", err)
}
c.ReactionCount = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatStatisticsInteractionInfo) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode chatStatisticsInteractionInfo#694a9a8d as nil")
}
b.ObjStart()
b.PutID("chatStatisticsInteractionInfo")
b.Comma()
b.FieldStart("object_type")
if c.ObjectType == nil {
return fmt.Errorf("unable to encode chatStatisticsInteractionInfo#694a9a8d: field object_type is nil")
}
if err := c.ObjectType.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode chatStatisticsInteractionInfo#694a9a8d: field object_type: %w", err)
}
b.Comma()
b.FieldStart("view_count")
b.PutInt32(c.ViewCount)
b.Comma()
b.FieldStart("forward_count")
b.PutInt32(c.ForwardCount)
b.Comma()
b.FieldStart("reaction_count")
b.PutInt32(c.ReactionCount)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatStatisticsInteractionInfo) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode chatStatisticsInteractionInfo#694a9a8d to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("chatStatisticsInteractionInfo"); err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: %w", err)
}
case "object_type":
value, err := DecodeTDLibJSONChatStatisticsObjectType(b)
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field object_type: %w", err)
}
c.ObjectType = value
case "view_count":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field view_count: %w", err)
}
c.ViewCount = value
case "forward_count":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field forward_count: %w", err)
}
c.ForwardCount = value
case "reaction_count":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode chatStatisticsInteractionInfo#694a9a8d: field reaction_count: %w", err)
}
c.ReactionCount = value
default:
return b.Skip()
}
return nil
})
}
// GetObjectType returns value of ObjectType field.
func (c *ChatStatisticsInteractionInfo) GetObjectType() (value ChatStatisticsObjectTypeClass) {
if c == nil {
return
}
return c.ObjectType
}
// GetViewCount returns value of ViewCount field.
func (c *ChatStatisticsInteractionInfo) GetViewCount() (value int32) {
if c == nil {
return
}
return c.ViewCount
}
// GetForwardCount returns value of ForwardCount field.
func (c *ChatStatisticsInteractionInfo) GetForwardCount() (value int32) {
if c == nil {
return
}
return c.ForwardCount
}
// GetReactionCount returns value of ReactionCount field.
func (c *ChatStatisticsInteractionInfo) GetReactionCount() (value int32) {
if c == nil {
return
}
return c.ReactionCount
}