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 StoriesSendStoryRequest struct {
Flags bin .Fields
Pinned bool
Noforwards bool
FwdModified bool
Peer InputPeerClass
Media InputMediaClass
MediaAreas []MediaAreaClass
Caption string
Entities []MessageEntityClass
PrivacyRules []InputPrivacyRuleClass
RandomID int64
Period int
FwdFromID InputPeerClass
FwdFromStory int
}
const StoriesSendStoryRequestTypeID = 0xe4e6694b
var (
_ bin .Encoder = &StoriesSendStoryRequest {}
_ bin .Decoder = &StoriesSendStoryRequest {}
_ bin .BareEncoder = &StoriesSendStoryRequest {}
_ bin .BareDecoder = &StoriesSendStoryRequest {}
)
func (s *StoriesSendStoryRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Pinned == false ) {
return false
}
if !(s .Noforwards == false ) {
return false
}
if !(s .FwdModified == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .Media == nil ) {
return false
}
if !(s .MediaAreas == nil ) {
return false
}
if !(s .Caption == "" ) {
return false
}
if !(s .Entities == nil ) {
return false
}
if !(s .PrivacyRules == nil ) {
return false
}
if !(s .RandomID == 0 ) {
return false
}
if !(s .Period == 0 ) {
return false
}
if !(s .FwdFromID == nil ) {
return false
}
if !(s .FwdFromStory == 0 ) {
return false
}
return true
}
func (s *StoriesSendStoryRequest ) String () string {
if s == nil {
return "StoriesSendStoryRequest(nil)"
}
type Alias StoriesSendStoryRequest
return fmt .Sprintf ("StoriesSendStoryRequest%+v" , Alias (*s ))
}
func (s *StoriesSendStoryRequest ) FillFrom (from interface {
GetPinned () (value bool )
GetNoforwards () (value bool )
GetFwdModified () (value bool )
GetPeer () (value InputPeerClass )
GetMedia () (value InputMediaClass )
GetMediaAreas () (value []MediaAreaClass , ok bool )
GetCaption () (value string , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetPrivacyRules () (value []InputPrivacyRuleClass )
GetRandomID () (value int64 )
GetPeriod () (value int , ok bool )
GetFwdFromID () (value InputPeerClass , ok bool )
GetFwdFromStory () (value int , ok bool )
}) {
s .Pinned = from .GetPinned ()
s .Noforwards = from .GetNoforwards ()
s .FwdModified = from .GetFwdModified ()
s .Peer = from .GetPeer ()
s .Media = from .GetMedia ()
if val , ok := from .GetMediaAreas (); ok {
s .MediaAreas = val
}
if val , ok := from .GetCaption (); ok {
s .Caption = val
}
if val , ok := from .GetEntities (); ok {
s .Entities = val
}
s .PrivacyRules = from .GetPrivacyRules ()
s .RandomID = from .GetRandomID ()
if val , ok := from .GetPeriod (); ok {
s .Period = val
}
if val , ok := from .GetFwdFromID (); ok {
s .FwdFromID = val
}
if val , ok := from .GetFwdFromStory (); ok {
s .FwdFromStory = val
}
}
func (*StoriesSendStoryRequest ) TypeID () uint32 {
return StoriesSendStoryRequestTypeID
}
func (*StoriesSendStoryRequest ) TypeName () string {
return "stories.sendStory"
}
func (s *StoriesSendStoryRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.sendStory" ,
ID : StoriesSendStoryRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Pinned" ,
SchemaName : "pinned" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "FwdModified" ,
SchemaName : "fwd_modified" ,
Null : !s .Flags .Has (7 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Media" ,
SchemaName : "media" ,
},
{
Name : "MediaAreas" ,
SchemaName : "media_areas" ,
Null : !s .Flags .Has (5 ),
},
{
Name : "Caption" ,
SchemaName : "caption" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "PrivacyRules" ,
SchemaName : "privacy_rules" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "Period" ,
SchemaName : "period" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "FwdFromID" ,
SchemaName : "fwd_from_id" ,
Null : !s .Flags .Has (6 ),
},
{
Name : "FwdFromStory" ,
SchemaName : "fwd_from_story" ,
Null : !s .Flags .Has (6 ),
},
}
return typ
}
func (s *StoriesSendStoryRequest ) SetFlags () {
if !(s .Pinned == false ) {
s .Flags .Set (2 )
}
if !(s .Noforwards == false ) {
s .Flags .Set (4 )
}
if !(s .FwdModified == false ) {
s .Flags .Set (7 )
}
if !(s .MediaAreas == nil ) {
s .Flags .Set (5 )
}
if !(s .Caption == "" ) {
s .Flags .Set (0 )
}
if !(s .Entities == nil ) {
s .Flags .Set (1 )
}
if !(s .Period == 0 ) {
s .Flags .Set (3 )
}
if !(s .FwdFromID == nil ) {
s .Flags .Set (6 )
}
if !(s .FwdFromStory == 0 ) {
s .Flags .Set (6 )
}
}
func (s *StoriesSendStoryRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.sendStory#e4e6694b as nil" )
}
b .PutID (StoriesSendStoryRequestTypeID )
return s .EncodeBare (b )
}
func (s *StoriesSendStoryRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.sendStory#e4e6694b as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field peer: %w" , err )
}
if s .Media == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field media is nil" )
}
if err := s .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field media: %w" , err )
}
if s .Flags .Has (5 ) {
b .PutVectorHeader (len (s .MediaAreas ))
for idx , v := range s .MediaAreas {
if v == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field media_areas element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field media_areas element with index %d: %w" , idx , err )
}
}
}
if s .Flags .Has (0 ) {
b .PutString (s .Caption )
}
if s .Flags .Has (1 ) {
b .PutVectorHeader (len (s .Entities ))
for idx , v := range s .Entities {
if v == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field entities element with index %d: %w" , idx , err )
}
}
}
b .PutVectorHeader (len (s .PrivacyRules ))
for idx , v := range s .PrivacyRules {
if v == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field privacy_rules element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field privacy_rules element with index %d: %w" , idx , err )
}
}
b .PutLong (s .RandomID )
if s .Flags .Has (3 ) {
b .PutInt (s .Period )
}
if s .Flags .Has (6 ) {
if s .FwdFromID == nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field fwd_from_id is nil" )
}
if err := s .FwdFromID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.sendStory#e4e6694b: field fwd_from_id: %w" , err )
}
}
if s .Flags .Has (6 ) {
b .PutInt (s .FwdFromStory )
}
return nil
}
func (s *StoriesSendStoryRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.sendStory#e4e6694b to nil" )
}
if err := b .ConsumeID (StoriesSendStoryRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesSendStoryRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.sendStory#e4e6694b to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field flags: %w" , err )
}
}
s .Pinned = s .Flags .Has (2 )
s .Noforwards = s .Flags .Has (4 )
s .FwdModified = s .Flags .Has (7 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := DecodeInputMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field media: %w" , err )
}
s .Media = value
}
if s .Flags .Has (5 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field media_areas: %w" , err )
}
if headerLen > 0 {
s .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.sendStory#e4e6694b: field media_areas: %w" , err )
}
s .MediaAreas = append (s .MediaAreas , value )
}
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field caption: %w" , err )
}
s .Caption = value
}
if s .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field entities: %w" , err )
}
if headerLen > 0 {
s .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.sendStory#e4e6694b: field entities: %w" , err )
}
s .Entities = append (s .Entities , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field privacy_rules: %w" , err )
}
if headerLen > 0 {
s .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.sendStory#e4e6694b: field privacy_rules: %w" , err )
}
s .PrivacyRules = append (s .PrivacyRules , value )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field random_id: %w" , err )
}
s .RandomID = value
}
if s .Flags .Has (3 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field period: %w" , err )
}
s .Period = value
}
if s .Flags .Has (6 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field fwd_from_id: %w" , err )
}
s .FwdFromID = value
}
if s .Flags .Has (6 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.sendStory#e4e6694b: field fwd_from_story: %w" , err )
}
s .FwdFromStory = value
}
return nil
}
func (s *StoriesSendStoryRequest ) SetPinned (value bool ) {
if value {
s .Flags .Set (2 )
s .Pinned = true
} else {
s .Flags .Unset (2 )
s .Pinned = false
}
}
func (s *StoriesSendStoryRequest ) GetPinned () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (2 )
}
func (s *StoriesSendStoryRequest ) SetNoforwards (value bool ) {
if value {
s .Flags .Set (4 )
s .Noforwards = true
} else {
s .Flags .Unset (4 )
s .Noforwards = false
}
}
func (s *StoriesSendStoryRequest ) GetNoforwards () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (4 )
}
func (s *StoriesSendStoryRequest ) SetFwdModified (value bool ) {
if value {
s .Flags .Set (7 )
s .FwdModified = true
} else {
s .Flags .Unset (7 )
s .FwdModified = false
}
}
func (s *StoriesSendStoryRequest ) GetFwdModified () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (7 )
}
func (s *StoriesSendStoryRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *StoriesSendStoryRequest ) GetMedia () (value InputMediaClass ) {
if s == nil {
return
}
return s .Media
}
func (s *StoriesSendStoryRequest ) SetMediaAreas (value []MediaAreaClass ) {
s .Flags .Set (5 )
s .MediaAreas = value
}
func (s *StoriesSendStoryRequest ) GetMediaAreas () (value []MediaAreaClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (5 ) {
return value , false
}
return s .MediaAreas , true
}
func (s *StoriesSendStoryRequest ) SetCaption (value string ) {
s .Flags .Set (0 )
s .Caption = value
}
func (s *StoriesSendStoryRequest ) GetCaption () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Caption , true
}
func (s *StoriesSendStoryRequest ) SetEntities (value []MessageEntityClass ) {
s .Flags .Set (1 )
s .Entities = value
}
func (s *StoriesSendStoryRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Entities , true
}
func (s *StoriesSendStoryRequest ) GetPrivacyRules () (value []InputPrivacyRuleClass ) {
if s == nil {
return
}
return s .PrivacyRules
}
func (s *StoriesSendStoryRequest ) GetRandomID () (value int64 ) {
if s == nil {
return
}
return s .RandomID
}
func (s *StoriesSendStoryRequest ) SetPeriod (value int ) {
s .Flags .Set (3 )
s .Period = value
}
func (s *StoriesSendStoryRequest ) GetPeriod () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (3 ) {
return value , false
}
return s .Period , true
}
func (s *StoriesSendStoryRequest ) SetFwdFromID (value InputPeerClass ) {
s .Flags .Set (6 )
s .FwdFromID = value
}
func (s *StoriesSendStoryRequest ) GetFwdFromID () (value InputPeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (6 ) {
return value , false
}
return s .FwdFromID , true
}
func (s *StoriesSendStoryRequest ) SetFwdFromStory (value int ) {
s .Flags .Set (6 )
s .FwdFromStory = value
}
func (s *StoriesSendStoryRequest ) GetFwdFromStory () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (6 ) {
return value , false
}
return s .FwdFromStory , true
}
func (s *StoriesSendStoryRequest ) MapMediaAreas () (value MediaAreaClassArray , ok bool ) {
if !s .Flags .Has (5 ) {
return value , false
}
return MediaAreaClassArray (s .MediaAreas ), true
}
func (s *StoriesSendStoryRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !s .Flags .Has (1 ) {
return value , false
}
return MessageEntityClassArray (s .Entities ), true
}
func (s *StoriesSendStoryRequest ) MapPrivacyRules () (value InputPrivacyRuleClassArray ) {
return InputPrivacyRuleClassArray (s .PrivacyRules )
}
func (c *Client ) StoriesSendStory (ctx context .Context , request *StoriesSendStoryRequest ) (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 .