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

563 lines
14 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{}
)
// PostInteractionCountersMessage represents TL type `postInteractionCountersMessage#e7058e7f`.
// Interaction counters for a message.
//
// See https://core.telegram.org/constructor/postInteractionCountersMessage for reference.
type PostInteractionCountersMessage struct {
// Message ID
MsgID int
// Number of views
Views int
// Number of forwards to public channels
Forwards int
// Number of reactions
Reactions int
}
// PostInteractionCountersMessageTypeID is TL type id of PostInteractionCountersMessage.
const PostInteractionCountersMessageTypeID = 0xe7058e7f
// construct implements constructor of PostInteractionCountersClass.
func (p PostInteractionCountersMessage) construct() PostInteractionCountersClass { return &p }
// Ensuring interfaces in compile-time for PostInteractionCountersMessage.
var (
_ bin.Encoder = &PostInteractionCountersMessage{}
_ bin.Decoder = &PostInteractionCountersMessage{}
_ bin.BareEncoder = &PostInteractionCountersMessage{}
_ bin.BareDecoder = &PostInteractionCountersMessage{}
_ PostInteractionCountersClass = &PostInteractionCountersMessage{}
)
func (p *PostInteractionCountersMessage) Zero() bool {
if p == nil {
return true
}
if !(p.MsgID == 0) {
return false
}
if !(p.Views == 0) {
return false
}
if !(p.Forwards == 0) {
return false
}
if !(p.Reactions == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PostInteractionCountersMessage) String() string {
if p == nil {
return "PostInteractionCountersMessage(nil)"
}
type Alias PostInteractionCountersMessage
return fmt.Sprintf("PostInteractionCountersMessage%+v", Alias(*p))
}
// FillFrom fills PostInteractionCountersMessage from given interface.
func (p *PostInteractionCountersMessage) FillFrom(from interface {
GetMsgID() (value int)
GetViews() (value int)
GetForwards() (value int)
GetReactions() (value int)
}) {
p.MsgID = from.GetMsgID()
p.Views = from.GetViews()
p.Forwards = from.GetForwards()
p.Reactions = from.GetReactions()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PostInteractionCountersMessage) TypeID() uint32 {
return PostInteractionCountersMessageTypeID
}
// TypeName returns name of type in TL schema.
func (*PostInteractionCountersMessage) TypeName() string {
return "postInteractionCountersMessage"
}
// TypeInfo returns info about TL type.
func (p *PostInteractionCountersMessage) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "postInteractionCountersMessage",
ID: PostInteractionCountersMessageTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "MsgID",
SchemaName: "msg_id",
},
{
Name: "Views",
SchemaName: "views",
},
{
Name: "Forwards",
SchemaName: "forwards",
},
{
Name: "Reactions",
SchemaName: "reactions",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PostInteractionCountersMessage) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode postInteractionCountersMessage#e7058e7f as nil")
}
b.PutID(PostInteractionCountersMessageTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PostInteractionCountersMessage) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode postInteractionCountersMessage#e7058e7f as nil")
}
b.PutInt(p.MsgID)
b.PutInt(p.Views)
b.PutInt(p.Forwards)
b.PutInt(p.Reactions)
return nil
}
// Decode implements bin.Decoder.
func (p *PostInteractionCountersMessage) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode postInteractionCountersMessage#e7058e7f to nil")
}
if err := b.ConsumeID(PostInteractionCountersMessageTypeID); err != nil {
return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PostInteractionCountersMessage) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode postInteractionCountersMessage#e7058e7f to nil")
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field msg_id: %w", err)
}
p.MsgID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field views: %w", err)
}
p.Views = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field forwards: %w", err)
}
p.Forwards = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field reactions: %w", err)
}
p.Reactions = value
}
return nil
}
// GetMsgID returns value of MsgID field.
func (p *PostInteractionCountersMessage) GetMsgID() (value int) {
if p == nil {
return
}
return p.MsgID
}
// GetViews returns value of Views field.
func (p *PostInteractionCountersMessage) GetViews() (value int) {
if p == nil {
return
}
return p.Views
}
// GetForwards returns value of Forwards field.
func (p *PostInteractionCountersMessage) GetForwards() (value int) {
if p == nil {
return
}
return p.Forwards
}
// GetReactions returns value of Reactions field.
func (p *PostInteractionCountersMessage) GetReactions() (value int) {
if p == nil {
return
}
return p.Reactions
}
// PostInteractionCountersStory represents TL type `postInteractionCountersStory#8a480e27`.
// Interaction counters for a story.
//
// See https://core.telegram.org/constructor/postInteractionCountersStory for reference.
type PostInteractionCountersStory struct {
// Story ID
StoryID int
// Number of views
Views int
// Number of forwards and reposts to public chats and channels
Forwards int
// Number of reactions
Reactions int
}
// PostInteractionCountersStoryTypeID is TL type id of PostInteractionCountersStory.
const PostInteractionCountersStoryTypeID = 0x8a480e27
// construct implements constructor of PostInteractionCountersClass.
func (p PostInteractionCountersStory) construct() PostInteractionCountersClass { return &p }
// Ensuring interfaces in compile-time for PostInteractionCountersStory.
var (
_ bin.Encoder = &PostInteractionCountersStory{}
_ bin.Decoder = &PostInteractionCountersStory{}
_ bin.BareEncoder = &PostInteractionCountersStory{}
_ bin.BareDecoder = &PostInteractionCountersStory{}
_ PostInteractionCountersClass = &PostInteractionCountersStory{}
)
func (p *PostInteractionCountersStory) Zero() bool {
if p == nil {
return true
}
if !(p.StoryID == 0) {
return false
}
if !(p.Views == 0) {
return false
}
if !(p.Forwards == 0) {
return false
}
if !(p.Reactions == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PostInteractionCountersStory) String() string {
if p == nil {
return "PostInteractionCountersStory(nil)"
}
type Alias PostInteractionCountersStory
return fmt.Sprintf("PostInteractionCountersStory%+v", Alias(*p))
}
// FillFrom fills PostInteractionCountersStory from given interface.
func (p *PostInteractionCountersStory) FillFrom(from interface {
GetStoryID() (value int)
GetViews() (value int)
GetForwards() (value int)
GetReactions() (value int)
}) {
p.StoryID = from.GetStoryID()
p.Views = from.GetViews()
p.Forwards = from.GetForwards()
p.Reactions = from.GetReactions()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PostInteractionCountersStory) TypeID() uint32 {
return PostInteractionCountersStoryTypeID
}
// TypeName returns name of type in TL schema.
func (*PostInteractionCountersStory) TypeName() string {
return "postInteractionCountersStory"
}
// TypeInfo returns info about TL type.
func (p *PostInteractionCountersStory) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "postInteractionCountersStory",
ID: PostInteractionCountersStoryTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "StoryID",
SchemaName: "story_id",
},
{
Name: "Views",
SchemaName: "views",
},
{
Name: "Forwards",
SchemaName: "forwards",
},
{
Name: "Reactions",
SchemaName: "reactions",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PostInteractionCountersStory) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode postInteractionCountersStory#8a480e27 as nil")
}
b.PutID(PostInteractionCountersStoryTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PostInteractionCountersStory) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode postInteractionCountersStory#8a480e27 as nil")
}
b.PutInt(p.StoryID)
b.PutInt(p.Views)
b.PutInt(p.Forwards)
b.PutInt(p.Reactions)
return nil
}
// Decode implements bin.Decoder.
func (p *PostInteractionCountersStory) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode postInteractionCountersStory#8a480e27 to nil")
}
if err := b.ConsumeID(PostInteractionCountersStoryTypeID); err != nil {
return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PostInteractionCountersStory) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode postInteractionCountersStory#8a480e27 to nil")
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field story_id: %w", err)
}
p.StoryID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field views: %w", err)
}
p.Views = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field forwards: %w", err)
}
p.Forwards = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field reactions: %w", err)
}
p.Reactions = value
}
return nil
}
// GetStoryID returns value of StoryID field.
func (p *PostInteractionCountersStory) GetStoryID() (value int) {
if p == nil {
return
}
return p.StoryID
}
// GetViews returns value of Views field.
func (p *PostInteractionCountersStory) GetViews() (value int) {
if p == nil {
return
}
return p.Views
}
// GetForwards returns value of Forwards field.
func (p *PostInteractionCountersStory) GetForwards() (value int) {
if p == nil {
return
}
return p.Forwards
}
// GetReactions returns value of Reactions field.
func (p *PostInteractionCountersStory) GetReactions() (value int) {
if p == nil {
return
}
return p.Reactions
}
// PostInteractionCountersClassName is schema name of PostInteractionCountersClass.
const PostInteractionCountersClassName = "PostInteractionCounters"
// PostInteractionCountersClass represents PostInteractionCounters generic type.
//
// See https://core.telegram.org/type/PostInteractionCounters for reference.
//
// Example:
//
// g, err := tg.DecodePostInteractionCounters(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.PostInteractionCountersMessage: // postInteractionCountersMessage#e7058e7f
// case *tg.PostInteractionCountersStory: // postInteractionCountersStory#8a480e27
// default: panic(v)
// }
type PostInteractionCountersClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() PostInteractionCountersClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
// Number of views
GetViews() (value int)
// Number of forwards to public channels
GetForwards() (value int)
// Number of reactions
GetReactions() (value int)
}
// DecodePostInteractionCounters implements binary de-serialization for PostInteractionCountersClass.
func DecodePostInteractionCounters(buf *bin.Buffer) (PostInteractionCountersClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case PostInteractionCountersMessageTypeID:
// Decoding postInteractionCountersMessage#e7058e7f.
v := PostInteractionCountersMessage{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", err)
}
return &v, nil
case PostInteractionCountersStoryTypeID:
// Decoding postInteractionCountersStory#8a480e27.
v := PostInteractionCountersStory{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", bin.NewUnexpectedID(id))
}
}
// PostInteractionCounters boxes the PostInteractionCountersClass providing a helper.
type PostInteractionCountersBox struct {
PostInteractionCounters PostInteractionCountersClass
}
// Decode implements bin.Decoder for PostInteractionCountersBox.
func (b *PostInteractionCountersBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode PostInteractionCountersBox to nil")
}
v, err := DecodePostInteractionCounters(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.PostInteractionCounters = v
return nil
}
// Encode implements bin.Encode for PostInteractionCountersBox.
func (b *PostInteractionCountersBox) Encode(buf *bin.Buffer) error {
if b == nil || b.PostInteractionCounters == nil {
return fmt.Errorf("unable to encode PostInteractionCountersClass as nil")
}
return b.PostInteractionCounters.Encode(buf)
}