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 PostInteractionCountersMessage struct {
MsgID int
Views int
Forwards int
Reactions int
}
const PostInteractionCountersMessageTypeID = 0xe7058e7f
func (p PostInteractionCountersMessage ) construct () PostInteractionCountersClass { return &p }
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
}
func (p *PostInteractionCountersMessage ) String () string {
if p == nil {
return "PostInteractionCountersMessage(nil)"
}
type Alias PostInteractionCountersMessage
return fmt .Sprintf ("PostInteractionCountersMessage%+v" , Alias (*p ))
}
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 ()
}
func (*PostInteractionCountersMessage ) TypeID () uint32 {
return PostInteractionCountersMessageTypeID
}
func (*PostInteractionCountersMessage ) TypeName () string {
return "postInteractionCountersMessage"
}
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
}
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 )
}
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
}
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 )
}
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
}
func (p *PostInteractionCountersMessage ) GetMsgID () (value int ) {
if p == nil {
return
}
return p .MsgID
}
func (p *PostInteractionCountersMessage ) GetViews () (value int ) {
if p == nil {
return
}
return p .Views
}
func (p *PostInteractionCountersMessage ) GetForwards () (value int ) {
if p == nil {
return
}
return p .Forwards
}
func (p *PostInteractionCountersMessage ) GetReactions () (value int ) {
if p == nil {
return
}
return p .Reactions
}
type PostInteractionCountersStory struct {
StoryID int
Views int
Forwards int
Reactions int
}
const PostInteractionCountersStoryTypeID = 0x8a480e27
func (p PostInteractionCountersStory ) construct () PostInteractionCountersClass { return &p }
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
}
func (p *PostInteractionCountersStory ) String () string {
if p == nil {
return "PostInteractionCountersStory(nil)"
}
type Alias PostInteractionCountersStory
return fmt .Sprintf ("PostInteractionCountersStory%+v" , Alias (*p ))
}
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 ()
}
func (*PostInteractionCountersStory ) TypeID () uint32 {
return PostInteractionCountersStoryTypeID
}
func (*PostInteractionCountersStory ) TypeName () string {
return "postInteractionCountersStory"
}
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
}
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 )
}
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
}
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 )
}
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
}
func (p *PostInteractionCountersStory ) GetStoryID () (value int ) {
if p == nil {
return
}
return p .StoryID
}
func (p *PostInteractionCountersStory ) GetViews () (value int ) {
if p == nil {
return
}
return p .Views
}
func (p *PostInteractionCountersStory ) GetForwards () (value int ) {
if p == nil {
return
}
return p .Forwards
}
func (p *PostInteractionCountersStory ) GetReactions () (value int ) {
if p == nil {
return
}
return p .Reactions
}
const PostInteractionCountersClassName = "PostInteractionCounters"
type PostInteractionCountersClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PostInteractionCountersClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetViews () (value int )
GetForwards () (value int )
GetReactions () (value int )
}
func DecodePostInteractionCounters (buf *bin .Buffer ) (PostInteractionCountersClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PostInteractionCountersMessageTypeID :
v := PostInteractionCountersMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PostInteractionCountersClass: %w" , err )
}
return &v , nil
case PostInteractionCountersStoryTypeID :
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 ))
}
}
type PostInteractionCountersBox struct {
PostInteractionCounters PostInteractionCountersClass
}
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
}
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 )
}
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 .