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

641 lines
16 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{}
)
// StoryReaction represents TL type `storyReaction#6090d6d5`.
// How a certain peer reacted to a story
//
// See https://core.telegram.org/constructor/storyReaction for reference.
type StoryReaction struct {
// The peer
PeerID PeerClass
// Reaction date
Date int
// The reaction
Reaction ReactionClass
}
// StoryReactionTypeID is TL type id of StoryReaction.
const StoryReactionTypeID = 0x6090d6d5
// construct implements constructor of StoryReactionClass.
func (s StoryReaction) construct() StoryReactionClass { return &s }
// Ensuring interfaces in compile-time for StoryReaction.
var (
_ bin.Encoder = &StoryReaction{}
_ bin.Decoder = &StoryReaction{}
_ bin.BareEncoder = &StoryReaction{}
_ bin.BareDecoder = &StoryReaction{}
_ StoryReactionClass = &StoryReaction{}
)
func (s *StoryReaction) Zero() bool {
if s == nil {
return true
}
if !(s.PeerID == nil) {
return false
}
if !(s.Date == 0) {
return false
}
if !(s.Reaction == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StoryReaction) String() string {
if s == nil {
return "StoryReaction(nil)"
}
type Alias StoryReaction
return fmt.Sprintf("StoryReaction%+v", Alias(*s))
}
// FillFrom fills StoryReaction from given interface.
func (s *StoryReaction) FillFrom(from interface {
GetPeerID() (value PeerClass)
GetDate() (value int)
GetReaction() (value ReactionClass)
}) {
s.PeerID = from.GetPeerID()
s.Date = from.GetDate()
s.Reaction = from.GetReaction()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StoryReaction) TypeID() uint32 {
return StoryReactionTypeID
}
// TypeName returns name of type in TL schema.
func (*StoryReaction) TypeName() string {
return "storyReaction"
}
// TypeInfo returns info about TL type.
func (s *StoryReaction) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "storyReaction",
ID: StoryReactionTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "PeerID",
SchemaName: "peer_id",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "Reaction",
SchemaName: "reaction",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StoryReaction) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReaction#6090d6d5 as nil")
}
b.PutID(StoryReactionTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StoryReaction) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReaction#6090d6d5 as nil")
}
if s.PeerID == nil {
return fmt.Errorf("unable to encode storyReaction#6090d6d5: field peer_id is nil")
}
if err := s.PeerID.Encode(b); err != nil {
return fmt.Errorf("unable to encode storyReaction#6090d6d5: field peer_id: %w", err)
}
b.PutInt(s.Date)
if s.Reaction == nil {
return fmt.Errorf("unable to encode storyReaction#6090d6d5: field reaction is nil")
}
if err := s.Reaction.Encode(b); err != nil {
return fmt.Errorf("unable to encode storyReaction#6090d6d5: field reaction: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (s *StoryReaction) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReaction#6090d6d5 to nil")
}
if err := b.ConsumeID(StoryReactionTypeID); err != nil {
return fmt.Errorf("unable to decode storyReaction#6090d6d5: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StoryReaction) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReaction#6090d6d5 to nil")
}
{
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode storyReaction#6090d6d5: field peer_id: %w", err)
}
s.PeerID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode storyReaction#6090d6d5: field date: %w", err)
}
s.Date = value
}
{
value, err := DecodeReaction(b)
if err != nil {
return fmt.Errorf("unable to decode storyReaction#6090d6d5: field reaction: %w", err)
}
s.Reaction = value
}
return nil
}
// GetPeerID returns value of PeerID field.
func (s *StoryReaction) GetPeerID() (value PeerClass) {
if s == nil {
return
}
return s.PeerID
}
// GetDate returns value of Date field.
func (s *StoryReaction) GetDate() (value int) {
if s == nil {
return
}
return s.Date
}
// GetReaction returns value of Reaction field.
func (s *StoryReaction) GetReaction() (value ReactionClass) {
if s == nil {
return
}
return s.Reaction
}
// StoryReactionPublicForward represents TL type `storyReactionPublicForward#bbab2643`.
// A certain peer has forwarded the story as a message to a public chat or channel.
//
// See https://core.telegram.org/constructor/storyReactionPublicForward for reference.
type StoryReactionPublicForward struct {
// The message with the forwarded story.
Message MessageClass
}
// StoryReactionPublicForwardTypeID is TL type id of StoryReactionPublicForward.
const StoryReactionPublicForwardTypeID = 0xbbab2643
// construct implements constructor of StoryReactionClass.
func (s StoryReactionPublicForward) construct() StoryReactionClass { return &s }
// Ensuring interfaces in compile-time for StoryReactionPublicForward.
var (
_ bin.Encoder = &StoryReactionPublicForward{}
_ bin.Decoder = &StoryReactionPublicForward{}
_ bin.BareEncoder = &StoryReactionPublicForward{}
_ bin.BareDecoder = &StoryReactionPublicForward{}
_ StoryReactionClass = &StoryReactionPublicForward{}
)
func (s *StoryReactionPublicForward) Zero() bool {
if s == nil {
return true
}
if !(s.Message == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StoryReactionPublicForward) String() string {
if s == nil {
return "StoryReactionPublicForward(nil)"
}
type Alias StoryReactionPublicForward
return fmt.Sprintf("StoryReactionPublicForward%+v", Alias(*s))
}
// FillFrom fills StoryReactionPublicForward from given interface.
func (s *StoryReactionPublicForward) FillFrom(from interface {
GetMessage() (value MessageClass)
}) {
s.Message = from.GetMessage()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StoryReactionPublicForward) TypeID() uint32 {
return StoryReactionPublicForwardTypeID
}
// TypeName returns name of type in TL schema.
func (*StoryReactionPublicForward) TypeName() string {
return "storyReactionPublicForward"
}
// TypeInfo returns info about TL type.
func (s *StoryReactionPublicForward) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "storyReactionPublicForward",
ID: StoryReactionPublicForwardTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Message",
SchemaName: "message",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StoryReactionPublicForward) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReactionPublicForward#bbab2643 as nil")
}
b.PutID(StoryReactionPublicForwardTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StoryReactionPublicForward) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReactionPublicForward#bbab2643 as nil")
}
if s.Message == nil {
return fmt.Errorf("unable to encode storyReactionPublicForward#bbab2643: field message is nil")
}
if err := s.Message.Encode(b); err != nil {
return fmt.Errorf("unable to encode storyReactionPublicForward#bbab2643: field message: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (s *StoryReactionPublicForward) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReactionPublicForward#bbab2643 to nil")
}
if err := b.ConsumeID(StoryReactionPublicForwardTypeID); err != nil {
return fmt.Errorf("unable to decode storyReactionPublicForward#bbab2643: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StoryReactionPublicForward) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReactionPublicForward#bbab2643 to nil")
}
{
value, err := DecodeMessage(b)
if err != nil {
return fmt.Errorf("unable to decode storyReactionPublicForward#bbab2643: field message: %w", err)
}
s.Message = value
}
return nil
}
// GetMessage returns value of Message field.
func (s *StoryReactionPublicForward) GetMessage() (value MessageClass) {
if s == nil {
return
}
return s.Message
}
// StoryReactionPublicRepost represents TL type `storyReactionPublicRepost#cfcd0f13`.
// A certain peer has reposted the story.
//
// See https://core.telegram.org/constructor/storyReactionPublicRepost for reference.
type StoryReactionPublicRepost struct {
// The peer that reposted the story.
PeerID PeerClass
// The reposted story.
Story StoryItemClass
}
// StoryReactionPublicRepostTypeID is TL type id of StoryReactionPublicRepost.
const StoryReactionPublicRepostTypeID = 0xcfcd0f13
// construct implements constructor of StoryReactionClass.
func (s StoryReactionPublicRepost) construct() StoryReactionClass { return &s }
// Ensuring interfaces in compile-time for StoryReactionPublicRepost.
var (
_ bin.Encoder = &StoryReactionPublicRepost{}
_ bin.Decoder = &StoryReactionPublicRepost{}
_ bin.BareEncoder = &StoryReactionPublicRepost{}
_ bin.BareDecoder = &StoryReactionPublicRepost{}
_ StoryReactionClass = &StoryReactionPublicRepost{}
)
func (s *StoryReactionPublicRepost) Zero() bool {
if s == nil {
return true
}
if !(s.PeerID == nil) {
return false
}
if !(s.Story == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StoryReactionPublicRepost) String() string {
if s == nil {
return "StoryReactionPublicRepost(nil)"
}
type Alias StoryReactionPublicRepost
return fmt.Sprintf("StoryReactionPublicRepost%+v", Alias(*s))
}
// FillFrom fills StoryReactionPublicRepost from given interface.
func (s *StoryReactionPublicRepost) FillFrom(from interface {
GetPeerID() (value PeerClass)
GetStory() (value StoryItemClass)
}) {
s.PeerID = from.GetPeerID()
s.Story = from.GetStory()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StoryReactionPublicRepost) TypeID() uint32 {
return StoryReactionPublicRepostTypeID
}
// TypeName returns name of type in TL schema.
func (*StoryReactionPublicRepost) TypeName() string {
return "storyReactionPublicRepost"
}
// TypeInfo returns info about TL type.
func (s *StoryReactionPublicRepost) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "storyReactionPublicRepost",
ID: StoryReactionPublicRepostTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "PeerID",
SchemaName: "peer_id",
},
{
Name: "Story",
SchemaName: "story",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StoryReactionPublicRepost) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReactionPublicRepost#cfcd0f13 as nil")
}
b.PutID(StoryReactionPublicRepostTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StoryReactionPublicRepost) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode storyReactionPublicRepost#cfcd0f13 as nil")
}
if s.PeerID == nil {
return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field peer_id is nil")
}
if err := s.PeerID.Encode(b); err != nil {
return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field peer_id: %w", err)
}
if s.Story == nil {
return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field story is nil")
}
if err := s.Story.Encode(b); err != nil {
return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field story: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (s *StoryReactionPublicRepost) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReactionPublicRepost#cfcd0f13 to nil")
}
if err := b.ConsumeID(StoryReactionPublicRepostTypeID); err != nil {
return fmt.Errorf("unable to decode storyReactionPublicRepost#cfcd0f13: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StoryReactionPublicRepost) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode storyReactionPublicRepost#cfcd0f13 to nil")
}
{
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode storyReactionPublicRepost#cfcd0f13: field peer_id: %w", err)
}
s.PeerID = value
}
{
value, err := DecodeStoryItem(b)
if err != nil {
return fmt.Errorf("unable to decode storyReactionPublicRepost#cfcd0f13: field story: %w", err)
}
s.Story = value
}
return nil
}
// GetPeerID returns value of PeerID field.
func (s *StoryReactionPublicRepost) GetPeerID() (value PeerClass) {
if s == nil {
return
}
return s.PeerID
}
// GetStory returns value of Story field.
func (s *StoryReactionPublicRepost) GetStory() (value StoryItemClass) {
if s == nil {
return
}
return s.Story
}
// StoryReactionClassName is schema name of StoryReactionClass.
const StoryReactionClassName = "StoryReaction"
// StoryReactionClass represents StoryReaction generic type.
//
// See https://core.telegram.org/type/StoryReaction for reference.
//
// Example:
//
// g, err := tg.DecodeStoryReaction(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.StoryReaction: // storyReaction#6090d6d5
// case *tg.StoryReactionPublicForward: // storyReactionPublicForward#bbab2643
// case *tg.StoryReactionPublicRepost: // storyReactionPublicRepost#cfcd0f13
// default: panic(v)
// }
type StoryReactionClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() StoryReactionClass
// 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
}
// DecodeStoryReaction implements binary de-serialization for StoryReactionClass.
func DecodeStoryReaction(buf *bin.Buffer) (StoryReactionClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case StoryReactionTypeID:
// Decoding storyReaction#6090d6d5.
v := StoryReaction{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", err)
}
return &v, nil
case StoryReactionPublicForwardTypeID:
// Decoding storyReactionPublicForward#bbab2643.
v := StoryReactionPublicForward{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", err)
}
return &v, nil
case StoryReactionPublicRepostTypeID:
// Decoding storyReactionPublicRepost#cfcd0f13.
v := StoryReactionPublicRepost{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", bin.NewUnexpectedID(id))
}
}
// StoryReaction boxes the StoryReactionClass providing a helper.
type StoryReactionBox struct {
StoryReaction StoryReactionClass
}
// Decode implements bin.Decoder for StoryReactionBox.
func (b *StoryReactionBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode StoryReactionBox to nil")
}
v, err := DecodeStoryReaction(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.StoryReaction = v
return nil
}
// Encode implements bin.Encode for StoryReactionBox.
func (b *StoryReactionBox) Encode(buf *bin.Buffer) error {
if b == nil || b.StoryReaction == nil {
return fmt.Errorf("unable to encode StoryReactionClass as nil")
}
return b.StoryReaction.Encode(buf)
}