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 ChannelsRestrictSponsoredMessagesRequest struct {
Channel InputChannelClass
Restricted bool
}
const ChannelsRestrictSponsoredMessagesRequestTypeID = 0x9ae91519
var (
_ bin .Encoder = &ChannelsRestrictSponsoredMessagesRequest {}
_ bin .Decoder = &ChannelsRestrictSponsoredMessagesRequest {}
_ bin .BareEncoder = &ChannelsRestrictSponsoredMessagesRequest {}
_ bin .BareDecoder = &ChannelsRestrictSponsoredMessagesRequest {}
)
func (r *ChannelsRestrictSponsoredMessagesRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Channel == nil ) {
return false
}
if !(r .Restricted == false ) {
return false
}
return true
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) String () string {
if r == nil {
return "ChannelsRestrictSponsoredMessagesRequest(nil)"
}
type Alias ChannelsRestrictSponsoredMessagesRequest
return fmt .Sprintf ("ChannelsRestrictSponsoredMessagesRequest%+v" , Alias (*r ))
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetRestricted () (value bool )
}) {
r .Channel = from .GetChannel ()
r .Restricted = from .GetRestricted ()
}
func (*ChannelsRestrictSponsoredMessagesRequest ) TypeID () uint32 {
return ChannelsRestrictSponsoredMessagesRequestTypeID
}
func (*ChannelsRestrictSponsoredMessagesRequest ) TypeName () string {
return "channels.restrictSponsoredMessages"
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.restrictSponsoredMessages" ,
ID : ChannelsRestrictSponsoredMessagesRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Restricted" ,
SchemaName : "restricted" ,
},
}
return typ
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.restrictSponsoredMessages#9ae91519 as nil" )
}
b .PutID (ChannelsRestrictSponsoredMessagesRequestTypeID )
return r .EncodeBare (b )
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode channels.restrictSponsoredMessages#9ae91519 as nil" )
}
if r .Channel == nil {
return fmt .Errorf ("unable to encode channels.restrictSponsoredMessages#9ae91519: field channel is nil" )
}
if err := r .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.restrictSponsoredMessages#9ae91519: field channel: %w" , err )
}
b .PutBool (r .Restricted )
return nil
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.restrictSponsoredMessages#9ae91519 to nil" )
}
if err := b .ConsumeID (ChannelsRestrictSponsoredMessagesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.restrictSponsoredMessages#9ae91519: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode channels.restrictSponsoredMessages#9ae91519 to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.restrictSponsoredMessages#9ae91519: field channel: %w" , err )
}
r .Channel = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode channels.restrictSponsoredMessages#9ae91519: field restricted: %w" , err )
}
r .Restricted = value
}
return nil
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) GetChannel () (value InputChannelClass ) {
if r == nil {
return
}
return r .Channel
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) GetRestricted () (value bool ) {
if r == nil {
return
}
return r .Restricted
}
func (r *ChannelsRestrictSponsoredMessagesRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return r .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsRestrictSponsoredMessages (ctx context .Context , request *ChannelsRestrictSponsoredMessagesRequest ) (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 .