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 StoriesStartLiveRequest struct {
Flags bin .Fields
Pinned bool
Noforwards bool
RtmpStream bool
Peer InputPeerClass
Caption string
Entities []MessageEntityClass
PrivacyRules []InputPrivacyRuleClass
RandomID int64
MessagesEnabled bool
SendPaidMessagesStars int64
}
const StoriesStartLiveRequestTypeID = 0xd069ccde
var (
_ bin .Encoder = &StoriesStartLiveRequest {}
_ bin .Decoder = &StoriesStartLiveRequest {}
_ bin .BareEncoder = &StoriesStartLiveRequest {}
_ bin .BareDecoder = &StoriesStartLiveRequest {}
)
func (s *StoriesStartLiveRequest ) 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 .RtmpStream == false ) {
return false
}
if !(s .Peer == 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 .MessagesEnabled == false ) {
return false
}
if !(s .SendPaidMessagesStars == 0 ) {
return false
}
return true
}
func (s *StoriesStartLiveRequest ) String () string {
if s == nil {
return "StoriesStartLiveRequest(nil)"
}
type Alias StoriesStartLiveRequest
return fmt .Sprintf ("StoriesStartLiveRequest%+v" , Alias (*s ))
}
func (s *StoriesStartLiveRequest ) FillFrom (from interface {
GetPinned () (value bool )
GetNoforwards () (value bool )
GetRtmpStream () (value bool )
GetPeer () (value InputPeerClass )
GetCaption () (value string , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetPrivacyRules () (value []InputPrivacyRuleClass )
GetRandomID () (value int64 )
GetMessagesEnabled () (value bool , ok bool )
GetSendPaidMessagesStars () (value int64 , ok bool )
}) {
s .Pinned = from .GetPinned ()
s .Noforwards = from .GetNoforwards ()
s .RtmpStream = from .GetRtmpStream ()
s .Peer = from .GetPeer ()
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 .GetMessagesEnabled (); ok {
s .MessagesEnabled = val
}
if val , ok := from .GetSendPaidMessagesStars (); ok {
s .SendPaidMessagesStars = val
}
}
func (*StoriesStartLiveRequest ) TypeID () uint32 {
return StoriesStartLiveRequestTypeID
}
func (*StoriesStartLiveRequest ) TypeName () string {
return "stories.startLive"
}
func (s *StoriesStartLiveRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.startLive" ,
ID : StoriesStartLiveRequestTypeID ,
}
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 : "RtmpStream" ,
SchemaName : "rtmp_stream" ,
Null : !s .Flags .Has (5 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
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 : "MessagesEnabled" ,
SchemaName : "messages_enabled" ,
Null : !s .Flags .Has (6 ),
},
{
Name : "SendPaidMessagesStars" ,
SchemaName : "send_paid_messages_stars" ,
Null : !s .Flags .Has (7 ),
},
}
return typ
}
func (s *StoriesStartLiveRequest ) SetFlags () {
if !(s .Pinned == false ) {
s .Flags .Set (2 )
}
if !(s .Noforwards == false ) {
s .Flags .Set (4 )
}
if !(s .RtmpStream == false ) {
s .Flags .Set (5 )
}
if !(s .Caption == "" ) {
s .Flags .Set (0 )
}
if !(s .Entities == nil ) {
s .Flags .Set (1 )
}
if !(s .MessagesEnabled == false ) {
s .Flags .Set (6 )
}
if !(s .SendPaidMessagesStars == 0 ) {
s .Flags .Set (7 )
}
}
func (s *StoriesStartLiveRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.startLive#d069ccde as nil" )
}
b .PutID (StoriesStartLiveRequestTypeID )
return s .EncodeBare (b )
}
func (s *StoriesStartLiveRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.startLive#d069ccde as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.startLive#d069ccde: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode stories.startLive#d069ccde: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.startLive#d069ccde: field peer: %w" , 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.startLive#d069ccde: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.startLive#d069ccde: 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.startLive#d069ccde: field privacy_rules element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.startLive#d069ccde: field privacy_rules element with index %d: %w" , idx , err )
}
}
b .PutLong (s .RandomID )
if s .Flags .Has (6 ) {
b .PutBool (s .MessagesEnabled )
}
if s .Flags .Has (7 ) {
b .PutLong (s .SendPaidMessagesStars )
}
return nil
}
func (s *StoriesStartLiveRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.startLive#d069ccde to nil" )
}
if err := b .ConsumeID (StoriesStartLiveRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesStartLiveRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.startLive#d069ccde to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: field flags: %w" , err )
}
}
s .Pinned = s .Flags .Has (2 )
s .Noforwards = s .Flags .Has (4 )
s .RtmpStream = s .Flags .Has (5 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: 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.startLive#d069ccde: 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.startLive#d069ccde: field entities: %w" , err )
}
s .Entities = append (s .Entities , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: 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.startLive#d069ccde: 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.startLive#d069ccde: field random_id: %w" , err )
}
s .RandomID = value
}
if s .Flags .Has (6 ) {
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: field messages_enabled: %w" , err )
}
s .MessagesEnabled = value
}
if s .Flags .Has (7 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stories.startLive#d069ccde: field send_paid_messages_stars: %w" , err )
}
s .SendPaidMessagesStars = value
}
return nil
}
func (s *StoriesStartLiveRequest ) SetPinned (value bool ) {
if value {
s .Flags .Set (2 )
s .Pinned = true
} else {
s .Flags .Unset (2 )
s .Pinned = false
}
}
func (s *StoriesStartLiveRequest ) GetPinned () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (2 )
}
func (s *StoriesStartLiveRequest ) SetNoforwards (value bool ) {
if value {
s .Flags .Set (4 )
s .Noforwards = true
} else {
s .Flags .Unset (4 )
s .Noforwards = false
}
}
func (s *StoriesStartLiveRequest ) GetNoforwards () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (4 )
}
func (s *StoriesStartLiveRequest ) SetRtmpStream (value bool ) {
if value {
s .Flags .Set (5 )
s .RtmpStream = true
} else {
s .Flags .Unset (5 )
s .RtmpStream = false
}
}
func (s *StoriesStartLiveRequest ) GetRtmpStream () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (5 )
}
func (s *StoriesStartLiveRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *StoriesStartLiveRequest ) SetCaption (value string ) {
s .Flags .Set (0 )
s .Caption = value
}
func (s *StoriesStartLiveRequest ) GetCaption () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Caption , true
}
func (s *StoriesStartLiveRequest ) SetEntities (value []MessageEntityClass ) {
s .Flags .Set (1 )
s .Entities = value
}
func (s *StoriesStartLiveRequest ) GetEntities () (value []MessageEntityClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Entities , true
}
func (s *StoriesStartLiveRequest ) GetPrivacyRules () (value []InputPrivacyRuleClass ) {
if s == nil {
return
}
return s .PrivacyRules
}
func (s *StoriesStartLiveRequest ) GetRandomID () (value int64 ) {
if s == nil {
return
}
return s .RandomID
}
func (s *StoriesStartLiveRequest ) SetMessagesEnabled (value bool ) {
s .Flags .Set (6 )
s .MessagesEnabled = value
}
func (s *StoriesStartLiveRequest ) GetMessagesEnabled () (value bool , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (6 ) {
return value , false
}
return s .MessagesEnabled , true
}
func (s *StoriesStartLiveRequest ) SetSendPaidMessagesStars (value int64 ) {
s .Flags .Set (7 )
s .SendPaidMessagesStars = value
}
func (s *StoriesStartLiveRequest ) GetSendPaidMessagesStars () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (7 ) {
return value , false
}
return s .SendPaidMessagesStars , true
}
func (s *StoriesStartLiveRequest ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !s .Flags .Has (1 ) {
return value , false
}
return MessageEntityClassArray (s .Entities ), true
}
func (s *StoriesStartLiveRequest ) MapPrivacyRules () (value InputPrivacyRuleClassArray ) {
return InputPrivacyRuleClassArray (s .PrivacyRules )
}
func (c *Client ) StoriesStartLive (ctx context .Context , request *StoriesStartLiveRequest ) (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.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .