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