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 StoriesEditStoryRequest struct {
Flags bin .Fields
Peer InputPeerClass
ID int
Media InputMediaClass
MediaAreas []MediaAreaClass
Caption string
Entities []MessageEntityClass
PrivacyRules []InputPrivacyRuleClass
}
const StoriesEditStoryRequestTypeID = 0xb583ba46
var (
_ bin .Encoder = &StoriesEditStoryRequest {}
_ bin .Decoder = &StoriesEditStoryRequest {}
_ bin .BareEncoder = &StoriesEditStoryRequest {}
_ bin .BareDecoder = &StoriesEditStoryRequest {}
)
func (e *StoriesEditStoryRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .Peer == nil ) {
return false
}
if !(e .ID == 0 ) {
return false
}
if !(e .Media == nil ) {
return false
}
if !(e .MediaAreas == nil ) {
return false
}
if !(e .Caption == "" ) {
return false
}
if !(e .Entities == nil ) {
return false
}
if !(e .PrivacyRules == nil ) {
return false
}
return true
}
func (e *StoriesEditStoryRequest ) String () string {
if e == nil {
return "StoriesEditStoryRequest(nil)"
}
type Alias StoriesEditStoryRequest
return fmt .Sprintf ("StoriesEditStoryRequest%+v" , Alias (*e ))
}
func (e *StoriesEditStoryRequest ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetID () (value int )
GetMedia () (value InputMediaClass , ok bool )
GetMediaAreas () (value []MediaAreaClass , ok bool )
GetCaption () (value string , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetPrivacyRules () (value []InputPrivacyRuleClass , ok bool )
}) {
e .Peer = from .GetPeer ()
e .ID = from .GetID ()
if val , ok := from .GetMedia (); ok {
e .Media = val
}
if val , ok := from .GetMediaAreas (); ok {
e .MediaAreas = val
}
if val , ok := from .GetCaption (); ok {
e .Caption = val
}
if val , ok := from .GetEntities (); ok {
e .Entities = val
}
if val , ok := from .GetPrivacyRules (); ok {
e .PrivacyRules = val
}
}
func (*StoriesEditStoryRequest ) TypeID () uint32 {
return StoriesEditStoryRequestTypeID
}
func (*StoriesEditStoryRequest ) TypeName () string {
return "stories.editStory"
}
func (e *StoriesEditStoryRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.editStory" ,
ID : StoriesEditStoryRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Media" ,
SchemaName : "media" ,
Null : !e .Flags .Has (0 ),
},
{
Name : "MediaAreas" ,
SchemaName : "media_areas" ,
Null : !e .Flags .Has (3 ),
},
{
Name : "Caption" ,
SchemaName : "caption" ,
Null : !e .Flags .Has (1 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !e .Flags .Has (1 ),
},
{
Name : "PrivacyRules" ,
SchemaName : "privacy_rules" ,
Null : !e .Flags .Has (2 ),
},
}
return typ
}
func (e *StoriesEditStoryRequest ) SetFlags () {
if !(e .Media == nil ) {
e .Flags .Set (0 )
}
if !(e .MediaAreas == nil ) {
e .Flags .Set (3 )
}
if !(e .Caption == "" ) {
e .Flags .Set (1 )
}
if !(e .Entities == nil ) {
e .Flags .Set (1 )
}
if !(e .PrivacyRules == nil ) {
e .Flags .Set (2 )
}
}
func (e *StoriesEditStoryRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode stories.editStory#b583ba46 as nil" )
}
b .PutID (StoriesEditStoryRequestTypeID )
return e .EncodeBare (b )
}
func (e *StoriesEditStoryRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode stories.editStory#b583ba46 as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field flags: %w" , err )
}
if e .Peer == nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field peer is nil" )
}
if err := e .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field peer: %w" , err )
}
b .PutInt (e .ID )
if e .Flags .Has (0 ) {
if e .Media == nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field media is nil" )
}
if err := e .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field media: %w" , err )
}
}
if e .Flags .Has (3 ) {
b .PutVectorHeader (len (e .MediaAreas ))
for idx , v := range e .MediaAreas {
if v == nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field media_areas element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field media_areas element with index %d: %w" , idx , err )
}
}
}
if e .Flags .Has (1 ) {
b .PutString (e .Caption )
}
if e .Flags .Has (1 ) {
b .PutVectorHeader (len (e .Entities ))
for idx , v := range e .Entities {
if v == nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field entities element with index %d: %w" , idx , err )
}
}
}
if e .Flags .Has (2 ) {
b .PutVectorHeader (len (e .PrivacyRules ))
for idx , v := range e .PrivacyRules {
if v == nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field privacy_rules element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.editStory#b583ba46: field privacy_rules element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (e *StoriesEditStoryRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode stories.editStory#b583ba46 to nil" )
}
if err := b .ConsumeID (StoriesEditStoryRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: %w" , err )
}
return e .DecodeBare (b )
}
func (e *StoriesEditStoryRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode stories.editStory#b583ba46 to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field flags: %w" , err )
}
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field peer: %w" , err )
}
e .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field id: %w" , err )
}
e .ID = value
}
if e .Flags .Has (0 ) {
value , err := DecodeInputMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field media: %w" , err )
}
e .Media = value
}
if e .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field media_areas: %w" , err )
}
if headerLen > 0 {
e .MediaAreas = make ([]MediaAreaClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMediaArea (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field media_areas: %w" , err )
}
e .MediaAreas = append (e .MediaAreas , value )
}
}
if e .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field caption: %w" , err )
}
e .Caption = value
}
if e .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field entities: %w" , err )
}
if headerLen > 0 {
e .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field entities: %w" , err )
}
e .Entities = append (e .Entities , value )
}
}
if e .Flags .Has (2 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field privacy_rules: %w" , err )
}
if headerLen > 0 {
e .PrivacyRules = make ([]InputPrivacyRuleClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPrivacyRule (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.editStory#b583ba46: field privacy_rules: %w" , err )
}
e .PrivacyRules = append (e .PrivacyRules , value )
}
}
return nil
}
func (e *StoriesEditStoryRequest ) GetPeer () (value InputPeerClass ) {
if e == nil {
return
}
return e .Peer
}
func (e *StoriesEditStoryRequest ) GetID () (value int ) {
if e == nil {
return
}
return e .ID
}
func (e *StoriesEditStoryRequest ) SetMedia (value InputMediaClass ) {
e .Flags .Set (0 )
e .Media = value
}
func (e *StoriesEditStoryRequest ) GetMedia () (value InputMediaClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (0 ) {
return value , false
}
return e .Media , true
}
func (e *StoriesEditStoryRequest ) SetMediaAreas (value []MediaAreaClass ) {
e .Flags .Set (3 )
e .MediaAreas = value
}
func (e *StoriesEditStoryRequest ) GetMediaAreas () (value []MediaAreaClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (3 ) {
return value , false
}
return e .MediaAreas , true
}
func (e *StoriesEditStoryRequest ) SetCaption (value string ) {
e .Flags .Set (1 )
e .Caption = value
}
func (e *StoriesEditStoryRequest ) GetCaption () (value string , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (1 ) {
return value , false
}
return e .Caption , true
}
func (e *StoriesEditStoryRequest ) SetEntities (value []MessageEntityClass ) {
e .Flags .Set (1 )
e .Entities = value
}
func (e *StoriesEditStoryRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (1 ) {
return value , false
}
return e .Entities , true
}
func (e *StoriesEditStoryRequest ) SetPrivacyRules (value []InputPrivacyRuleClass ) {
e .Flags .Set (2 )
e .PrivacyRules = value
}
func (e *StoriesEditStoryRequest ) GetPrivacyRules () (value []InputPrivacyRuleClass , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (2 ) {
return value , false
}
return e .PrivacyRules , true
}
func (e *StoriesEditStoryRequest ) MapMediaAreas () (value MediaAreaClassArray , ok bool ) {
if !e .Flags .Has (3 ) {
return value , false
}
return MediaAreaClassArray (e .MediaAreas ), true
}
func (e *StoriesEditStoryRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !e .Flags .Has (1 ) {
return value , false
}
return MessageEntityClassArray (e .Entities ), true
}
func (e *StoriesEditStoryRequest ) MapPrivacyRules () (value InputPrivacyRuleClassArray , ok bool ) {
if !e .Flags .Has (2 ) {
return value , false
}
return InputPrivacyRuleClassArray (e .PrivacyRules ), true
}
func (c *Client ) StoriesEditStory (ctx context .Context , request *StoriesEditStoryRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , nil
}
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 .