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 StoryView struct {
Flags bin .Fields
Blocked bool
BlockedMyStoriesFrom bool
UserID int64
Date int
Reaction ReactionClass
}
const StoryViewTypeID = 0xb0bdeac5
func (s StoryView ) construct () StoryViewClass { return &s }
var (
_ bin .Encoder = &StoryView {}
_ bin .Decoder = &StoryView {}
_ bin .BareEncoder = &StoryView {}
_ bin .BareDecoder = &StoryView {}
_ StoryViewClass = &StoryView {}
)
func (s *StoryView ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Blocked == false ) {
return false
}
if !(s .BlockedMyStoriesFrom == false ) {
return false
}
if !(s .UserID == 0 ) {
return false
}
if !(s .Date == 0 ) {
return false
}
if !(s .Reaction == nil ) {
return false
}
return true
}
func (s *StoryView ) String () string {
if s == nil {
return "StoryView(nil)"
}
type Alias StoryView
return fmt .Sprintf ("StoryView%+v" , Alias (*s ))
}
func (s *StoryView ) FillFrom (from interface {
GetBlocked () (value bool )
GetBlockedMyStoriesFrom () (value bool )
GetUserID () (value int64 )
GetDate () (value int )
GetReaction () (value ReactionClass , ok bool )
}) {
s .Blocked = from .GetBlocked ()
s .BlockedMyStoriesFrom = from .GetBlockedMyStoriesFrom ()
s .UserID = from .GetUserID ()
s .Date = from .GetDate ()
if val , ok := from .GetReaction (); ok {
s .Reaction = val
}
}
func (*StoryView ) TypeID () uint32 {
return StoryViewTypeID
}
func (*StoryView ) TypeName () string {
return "storyView"
}
func (s *StoryView ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "storyView" ,
ID : StoryViewTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Blocked" ,
SchemaName : "blocked" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "BlockedMyStoriesFrom" ,
SchemaName : "blocked_my_stories_from" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Reaction" ,
SchemaName : "reaction" ,
Null : !s .Flags .Has (2 ),
},
}
return typ
}
func (s *StoryView ) SetFlags () {
if !(s .Blocked == false ) {
s .Flags .Set (0 )
}
if !(s .BlockedMyStoriesFrom == false ) {
s .Flags .Set (1 )
}
if !(s .Reaction == nil ) {
s .Flags .Set (2 )
}
}
func (s *StoryView ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyView#b0bdeac5 as nil" )
}
b .PutID (StoryViewTypeID )
return s .EncodeBare (b )
}
func (s *StoryView ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyView#b0bdeac5 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyView#b0bdeac5: field flags: %w" , err )
}
b .PutLong (s .UserID )
b .PutInt (s .Date )
if s .Flags .Has (2 ) {
if s .Reaction == nil {
return fmt .Errorf ("unable to encode storyView#b0bdeac5: field reaction is nil" )
}
if err := s .Reaction .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyView#b0bdeac5: field reaction: %w" , err )
}
}
return nil
}
func (s *StoryView ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyView#b0bdeac5 to nil" )
}
if err := b .ConsumeID (StoryViewTypeID ); err != nil {
return fmt .Errorf ("unable to decode storyView#b0bdeac5: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoryView ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyView#b0bdeac5 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode storyView#b0bdeac5: field flags: %w" , err )
}
}
s .Blocked = s .Flags .Has (0 )
s .BlockedMyStoriesFrom = s .Flags .Has (1 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode storyView#b0bdeac5: field user_id: %w" , err )
}
s .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode storyView#b0bdeac5: field date: %w" , err )
}
s .Date = value
}
if s .Flags .Has (2 ) {
value , err := DecodeReaction (b )
if err != nil {
return fmt .Errorf ("unable to decode storyView#b0bdeac5: field reaction: %w" , err )
}
s .Reaction = value
}
return nil
}
func (s *StoryView ) SetBlocked (value bool ) {
if value {
s .Flags .Set (0 )
s .Blocked = true
} else {
s .Flags .Unset (0 )
s .Blocked = false
}
}
func (s *StoryView ) GetBlocked () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *StoryView ) SetBlockedMyStoriesFrom (value bool ) {
if value {
s .Flags .Set (1 )
s .BlockedMyStoriesFrom = true
} else {
s .Flags .Unset (1 )
s .BlockedMyStoriesFrom = false
}
}
func (s *StoryView ) GetBlockedMyStoriesFrom () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StoryView ) GetUserID () (value int64 ) {
if s == nil {
return
}
return s .UserID
}
func (s *StoryView ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
func (s *StoryView ) SetReaction (value ReactionClass ) {
s .Flags .Set (2 )
s .Reaction = value
}
func (s *StoryView ) GetReaction () (value ReactionClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .Reaction , true
}
type StoryViewPublicForward struct {
Flags bin .Fields
Blocked bool
BlockedMyStoriesFrom bool
Message MessageClass
}
const StoryViewPublicForwardTypeID = 0x9083670b
func (s StoryViewPublicForward ) construct () StoryViewClass { return &s }
var (
_ bin .Encoder = &StoryViewPublicForward {}
_ bin .Decoder = &StoryViewPublicForward {}
_ bin .BareEncoder = &StoryViewPublicForward {}
_ bin .BareDecoder = &StoryViewPublicForward {}
_ StoryViewClass = &StoryViewPublicForward {}
)
func (s *StoryViewPublicForward ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Blocked == false ) {
return false
}
if !(s .BlockedMyStoriesFrom == false ) {
return false
}
if !(s .Message == nil ) {
return false
}
return true
}
func (s *StoryViewPublicForward ) String () string {
if s == nil {
return "StoryViewPublicForward(nil)"
}
type Alias StoryViewPublicForward
return fmt .Sprintf ("StoryViewPublicForward%+v" , Alias (*s ))
}
func (s *StoryViewPublicForward ) FillFrom (from interface {
GetBlocked () (value bool )
GetBlockedMyStoriesFrom () (value bool )
GetMessage () (value MessageClass )
}) {
s .Blocked = from .GetBlocked ()
s .BlockedMyStoriesFrom = from .GetBlockedMyStoriesFrom ()
s .Message = from .GetMessage ()
}
func (*StoryViewPublicForward ) TypeID () uint32 {
return StoryViewPublicForwardTypeID
}
func (*StoryViewPublicForward ) TypeName () string {
return "storyViewPublicForward"
}
func (s *StoryViewPublicForward ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "storyViewPublicForward" ,
ID : StoryViewPublicForwardTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Blocked" ,
SchemaName : "blocked" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "BlockedMyStoriesFrom" ,
SchemaName : "blocked_my_stories_from" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Message" ,
SchemaName : "message" ,
},
}
return typ
}
func (s *StoryViewPublicForward ) SetFlags () {
if !(s .Blocked == false ) {
s .Flags .Set (0 )
}
if !(s .BlockedMyStoriesFrom == false ) {
s .Flags .Set (1 )
}
}
func (s *StoryViewPublicForward ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyViewPublicForward#9083670b as nil" )
}
b .PutID (StoryViewPublicForwardTypeID )
return s .EncodeBare (b )
}
func (s *StoryViewPublicForward ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyViewPublicForward#9083670b as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyViewPublicForward#9083670b: field flags: %w" , err )
}
if s .Message == nil {
return fmt .Errorf ("unable to encode storyViewPublicForward#9083670b: field message is nil" )
}
if err := s .Message .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyViewPublicForward#9083670b: field message: %w" , err )
}
return nil
}
func (s *StoryViewPublicForward ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyViewPublicForward#9083670b to nil" )
}
if err := b .ConsumeID (StoryViewPublicForwardTypeID ); err != nil {
return fmt .Errorf ("unable to decode storyViewPublicForward#9083670b: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoryViewPublicForward ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyViewPublicForward#9083670b to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode storyViewPublicForward#9083670b: field flags: %w" , err )
}
}
s .Blocked = s .Flags .Has (0 )
s .BlockedMyStoriesFrom = s .Flags .Has (1 )
{
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode storyViewPublicForward#9083670b: field message: %w" , err )
}
s .Message = value
}
return nil
}
func (s *StoryViewPublicForward ) SetBlocked (value bool ) {
if value {
s .Flags .Set (0 )
s .Blocked = true
} else {
s .Flags .Unset (0 )
s .Blocked = false
}
}
func (s *StoryViewPublicForward ) GetBlocked () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *StoryViewPublicForward ) SetBlockedMyStoriesFrom (value bool ) {
if value {
s .Flags .Set (1 )
s .BlockedMyStoriesFrom = true
} else {
s .Flags .Unset (1 )
s .BlockedMyStoriesFrom = false
}
}
func (s *StoryViewPublicForward ) GetBlockedMyStoriesFrom () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StoryViewPublicForward ) GetMessage () (value MessageClass ) {
if s == nil {
return
}
return s .Message
}
type StoryViewPublicRepost struct {
Flags bin .Fields
Blocked bool
BlockedMyStoriesFrom bool
PeerID PeerClass
Story StoryItemClass
}
const StoryViewPublicRepostTypeID = 0xbd74cf49
func (s StoryViewPublicRepost ) construct () StoryViewClass { return &s }
var (
_ bin .Encoder = &StoryViewPublicRepost {}
_ bin .Decoder = &StoryViewPublicRepost {}
_ bin .BareEncoder = &StoryViewPublicRepost {}
_ bin .BareDecoder = &StoryViewPublicRepost {}
_ StoryViewClass = &StoryViewPublicRepost {}
)
func (s *StoryViewPublicRepost ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Blocked == false ) {
return false
}
if !(s .BlockedMyStoriesFrom == false ) {
return false
}
if !(s .PeerID == nil ) {
return false
}
if !(s .Story == nil ) {
return false
}
return true
}
func (s *StoryViewPublicRepost ) String () string {
if s == nil {
return "StoryViewPublicRepost(nil)"
}
type Alias StoryViewPublicRepost
return fmt .Sprintf ("StoryViewPublicRepost%+v" , Alias (*s ))
}
func (s *StoryViewPublicRepost ) FillFrom (from interface {
GetBlocked () (value bool )
GetBlockedMyStoriesFrom () (value bool )
GetPeerID () (value PeerClass )
GetStory () (value StoryItemClass )
}) {
s .Blocked = from .GetBlocked ()
s .BlockedMyStoriesFrom = from .GetBlockedMyStoriesFrom ()
s .PeerID = from .GetPeerID ()
s .Story = from .GetStory ()
}
func (*StoryViewPublicRepost ) TypeID () uint32 {
return StoryViewPublicRepostTypeID
}
func (*StoryViewPublicRepost ) TypeName () string {
return "storyViewPublicRepost"
}
func (s *StoryViewPublicRepost ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "storyViewPublicRepost" ,
ID : StoryViewPublicRepostTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Blocked" ,
SchemaName : "blocked" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "BlockedMyStoriesFrom" ,
SchemaName : "blocked_my_stories_from" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "PeerID" ,
SchemaName : "peer_id" ,
},
{
Name : "Story" ,
SchemaName : "story" ,
},
}
return typ
}
func (s *StoryViewPublicRepost ) SetFlags () {
if !(s .Blocked == false ) {
s .Flags .Set (0 )
}
if !(s .BlockedMyStoriesFrom == false ) {
s .Flags .Set (1 )
}
}
func (s *StoryViewPublicRepost ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyViewPublicRepost#bd74cf49 as nil" )
}
b .PutID (StoryViewPublicRepostTypeID )
return s .EncodeBare (b )
}
func (s *StoryViewPublicRepost ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode storyViewPublicRepost#bd74cf49 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyViewPublicRepost#bd74cf49: field flags: %w" , err )
}
if s .PeerID == nil {
return fmt .Errorf ("unable to encode storyViewPublicRepost#bd74cf49: field peer_id is nil" )
}
if err := s .PeerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyViewPublicRepost#bd74cf49: field peer_id: %w" , err )
}
if s .Story == nil {
return fmt .Errorf ("unable to encode storyViewPublicRepost#bd74cf49: field story is nil" )
}
if err := s .Story .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode storyViewPublicRepost#bd74cf49: field story: %w" , err )
}
return nil
}
func (s *StoryViewPublicRepost ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyViewPublicRepost#bd74cf49 to nil" )
}
if err := b .ConsumeID (StoryViewPublicRepostTypeID ); err != nil {
return fmt .Errorf ("unable to decode storyViewPublicRepost#bd74cf49: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoryViewPublicRepost ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode storyViewPublicRepost#bd74cf49 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode storyViewPublicRepost#bd74cf49: field flags: %w" , err )
}
}
s .Blocked = s .Flags .Has (0 )
s .BlockedMyStoriesFrom = s .Flags .Has (1 )
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode storyViewPublicRepost#bd74cf49: field peer_id: %w" , err )
}
s .PeerID = value
}
{
value , err := DecodeStoryItem (b )
if err != nil {
return fmt .Errorf ("unable to decode storyViewPublicRepost#bd74cf49: field story: %w" , err )
}
s .Story = value
}
return nil
}
func (s *StoryViewPublicRepost ) SetBlocked (value bool ) {
if value {
s .Flags .Set (0 )
s .Blocked = true
} else {
s .Flags .Unset (0 )
s .Blocked = false
}
}
func (s *StoryViewPublicRepost ) GetBlocked () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *StoryViewPublicRepost ) SetBlockedMyStoriesFrom (value bool ) {
if value {
s .Flags .Set (1 )
s .BlockedMyStoriesFrom = true
} else {
s .Flags .Unset (1 )
s .BlockedMyStoriesFrom = false
}
}
func (s *StoryViewPublicRepost ) GetBlockedMyStoriesFrom () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StoryViewPublicRepost ) GetPeerID () (value PeerClass ) {
if s == nil {
return
}
return s .PeerID
}
func (s *StoryViewPublicRepost ) GetStory () (value StoryItemClass ) {
if s == nil {
return
}
return s .Story
}
const StoryViewClassName = "StoryView"
type StoryViewClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StoryViewClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetBlocked () (value bool )
GetBlockedMyStoriesFrom () (value bool )
}
func DecodeStoryView (buf *bin .Buffer ) (StoryViewClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StoryViewTypeID :
v := StoryView {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoryViewClass: %w" , err )
}
return &v , nil
case StoryViewPublicForwardTypeID :
v := StoryViewPublicForward {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoryViewClass: %w" , err )
}
return &v , nil
case StoryViewPublicRepostTypeID :
v := StoryViewPublicRepost {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoryViewClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StoryViewClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StoryViewBox struct {
StoryView StoryViewClass
}
func (b *StoryViewBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StoryViewBox to nil" )
}
v , err := DecodeStoryView (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StoryView = v
return nil
}
func (b *StoryViewBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StoryView == nil {
return fmt .Errorf ("unable to encode StoryViewClass as nil" )
}
return b .StoryView .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 .