package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type StoryReaction struct {
PeerID PeerClass
Date int
Reaction ReactionClass
}
const StoryReactionTypeID = 0x6090d6d5
func (s StoryReaction ) construct () StoryReactionClass { return &s }
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
}
func (s *StoryReaction ) String () string {
if s == nil {
return "StoryReaction(nil)"
}
type Alias StoryReaction
return fmt .Sprintf ("StoryReaction%+v" , Alias (*s ))
}
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 ()
}
func (*StoryReaction ) TypeID () uint32 {
return StoryReactionTypeID
}
func (*StoryReaction ) TypeName () string {
return "storyReaction"
}
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
}
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 )
}
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
}
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 )
}
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
}
func (s *StoryReaction ) GetPeerID () (value PeerClass ) {
if s == nil {
return
}
return s .PeerID
}
func (s *StoryReaction ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
func (s *StoryReaction ) GetReaction () (value ReactionClass ) {
if s == nil {
return
}
return s .Reaction
}
type StoryReactionPublicForward struct {
Message MessageClass
}
const StoryReactionPublicForwardTypeID = 0xbbab2643
func (s StoryReactionPublicForward ) construct () StoryReactionClass { return &s }
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
}
func (s *StoryReactionPublicForward ) String () string {
if s == nil {
return "StoryReactionPublicForward(nil)"
}
type Alias StoryReactionPublicForward
return fmt .Sprintf ("StoryReactionPublicForward%+v" , Alias (*s ))
}
func (s *StoryReactionPublicForward ) FillFrom (from interface {
GetMessage () (value MessageClass )
}) {
s .Message = from .GetMessage ()
}
func (*StoryReactionPublicForward ) TypeID () uint32 {
return StoryReactionPublicForwardTypeID
}
func (*StoryReactionPublicForward ) TypeName () string {
return "storyReactionPublicForward"
}
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
}
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 )
}
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
}
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 )
}
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
}
func (s *StoryReactionPublicForward ) GetMessage () (value MessageClass ) {
if s == nil {
return
}
return s .Message
}
type StoryReactionPublicRepost struct {
PeerID PeerClass
Story StoryItemClass
}
const StoryReactionPublicRepostTypeID = 0xcfcd0f13
func (s StoryReactionPublicRepost ) construct () StoryReactionClass { return &s }
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
}
func (s *StoryReactionPublicRepost ) String () string {
if s == nil {
return "StoryReactionPublicRepost(nil)"
}
type Alias StoryReactionPublicRepost
return fmt .Sprintf ("StoryReactionPublicRepost%+v" , Alias (*s ))
}
func (s *StoryReactionPublicRepost ) FillFrom (from interface {
GetPeerID () (value PeerClass )
GetStory () (value StoryItemClass )
}) {
s .PeerID = from .GetPeerID ()
s .Story = from .GetStory ()
}
func (*StoryReactionPublicRepost ) TypeID () uint32 {
return StoryReactionPublicRepostTypeID
}
func (*StoryReactionPublicRepost ) TypeName () string {
return "storyReactionPublicRepost"
}
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
}
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 )
}
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
}
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 )
}
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
}
func (s *StoryReactionPublicRepost ) GetPeerID () (value PeerClass ) {
if s == nil {
return
}
return s .PeerID
}
func (s *StoryReactionPublicRepost ) GetStory () (value StoryItemClass ) {
if s == nil {
return
}
return s .Story
}
const StoryReactionClassName = "StoryReaction"
type StoryReactionClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StoryReactionClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeStoryReaction (buf *bin .Buffer ) (StoryReactionClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StoryReactionTypeID :
v := StoryReaction {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoryReactionClass: %w" , err )
}
return &v , nil
case StoryReactionPublicForwardTypeID :
v := StoryReactionPublicForward {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoryReactionClass: %w" , err )
}
return &v , nil
case StoryReactionPublicRepostTypeID :
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 ))
}
}
type StoryReactionBox struct {
StoryReaction StoryReactionClass
}
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
}
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 )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .