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 ChannelsClickSponsoredMessageRequest struct {
Channel InputChannelClass
RandomID []byte
}
const ChannelsClickSponsoredMessageRequestTypeID = 0x18afbc93
var (
_ bin .Encoder = &ChannelsClickSponsoredMessageRequest {}
_ bin .Decoder = &ChannelsClickSponsoredMessageRequest {}
_ bin .BareEncoder = &ChannelsClickSponsoredMessageRequest {}
_ bin .BareDecoder = &ChannelsClickSponsoredMessageRequest {}
)
func (c *ChannelsClickSponsoredMessageRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Channel == nil ) {
return false
}
if !(c .RandomID == nil ) {
return false
}
return true
}
func (c *ChannelsClickSponsoredMessageRequest ) String () string {
if c == nil {
return "ChannelsClickSponsoredMessageRequest(nil)"
}
type Alias ChannelsClickSponsoredMessageRequest
return fmt .Sprintf ("ChannelsClickSponsoredMessageRequest%+v" , Alias (*c ))
}
func (c *ChannelsClickSponsoredMessageRequest ) FillFrom (from interface {
GetChannel () (value InputChannelClass )
GetRandomID () (value []byte )
}) {
c .Channel = from .GetChannel ()
c .RandomID = from .GetRandomID ()
}
func (*ChannelsClickSponsoredMessageRequest ) TypeID () uint32 {
return ChannelsClickSponsoredMessageRequestTypeID
}
func (*ChannelsClickSponsoredMessageRequest ) TypeName () string {
return "channels.clickSponsoredMessage"
}
func (c *ChannelsClickSponsoredMessageRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.clickSponsoredMessage" ,
ID : ChannelsClickSponsoredMessageRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
}
return typ
}
func (c *ChannelsClickSponsoredMessageRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.clickSponsoredMessage#18afbc93 as nil" )
}
b .PutID (ChannelsClickSponsoredMessageRequestTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsClickSponsoredMessageRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.clickSponsoredMessage#18afbc93 as nil" )
}
if c .Channel == nil {
return fmt .Errorf ("unable to encode channels.clickSponsoredMessage#18afbc93: field channel is nil" )
}
if err := c .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.clickSponsoredMessage#18afbc93: field channel: %w" , err )
}
b .PutBytes (c .RandomID )
return nil
}
func (c *ChannelsClickSponsoredMessageRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.clickSponsoredMessage#18afbc93 to nil" )
}
if err := b .ConsumeID (ChannelsClickSponsoredMessageRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.clickSponsoredMessage#18afbc93: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsClickSponsoredMessageRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.clickSponsoredMessage#18afbc93 to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.clickSponsoredMessage#18afbc93: field channel: %w" , err )
}
c .Channel = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode channels.clickSponsoredMessage#18afbc93: field random_id: %w" , err )
}
c .RandomID = value
}
return nil
}
func (c *ChannelsClickSponsoredMessageRequest ) GetChannel () (value InputChannelClass ) {
if c == nil {
return
}
return c .Channel
}
func (c *ChannelsClickSponsoredMessageRequest ) GetRandomID () (value []byte ) {
if c == nil {
return
}
return c .RandomID
}
func (c *ChannelsClickSponsoredMessageRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return c .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsClickSponsoredMessage (ctx context .Context , request *ChannelsClickSponsoredMessageRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .