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 ChannelsSetDiscussionGroupRequest struct {
Broadcast InputChannelClass
Group InputChannelClass
}
const ChannelsSetDiscussionGroupRequestTypeID = 0x40582bb2
var (
_ bin .Encoder = &ChannelsSetDiscussionGroupRequest {}
_ bin .Decoder = &ChannelsSetDiscussionGroupRequest {}
_ bin .BareEncoder = &ChannelsSetDiscussionGroupRequest {}
_ bin .BareDecoder = &ChannelsSetDiscussionGroupRequest {}
)
func (s *ChannelsSetDiscussionGroupRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Broadcast == nil ) {
return false
}
if !(s .Group == nil ) {
return false
}
return true
}
func (s *ChannelsSetDiscussionGroupRequest ) String () string {
if s == nil {
return "ChannelsSetDiscussionGroupRequest(nil)"
}
type Alias ChannelsSetDiscussionGroupRequest
return fmt .Sprintf ("ChannelsSetDiscussionGroupRequest%+v" , Alias (*s ))
}
func (s *ChannelsSetDiscussionGroupRequest ) FillFrom (from interface {
GetBroadcast () (value InputChannelClass )
GetGroup () (value InputChannelClass )
}) {
s .Broadcast = from .GetBroadcast ()
s .Group = from .GetGroup ()
}
func (*ChannelsSetDiscussionGroupRequest ) TypeID () uint32 {
return ChannelsSetDiscussionGroupRequestTypeID
}
func (*ChannelsSetDiscussionGroupRequest ) TypeName () string {
return "channels.setDiscussionGroup"
}
func (s *ChannelsSetDiscussionGroupRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.setDiscussionGroup" ,
ID : ChannelsSetDiscussionGroupRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Broadcast" ,
SchemaName : "broadcast" ,
},
{
Name : "Group" ,
SchemaName : "group" ,
},
}
return typ
}
func (s *ChannelsSetDiscussionGroupRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode channels.setDiscussionGroup#40582bb2 as nil" )
}
b .PutID (ChannelsSetDiscussionGroupRequestTypeID )
return s .EncodeBare (b )
}
func (s *ChannelsSetDiscussionGroupRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode channels.setDiscussionGroup#40582bb2 as nil" )
}
if s .Broadcast == nil {
return fmt .Errorf ("unable to encode channels.setDiscussionGroup#40582bb2: field broadcast is nil" )
}
if err := s .Broadcast .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.setDiscussionGroup#40582bb2: field broadcast: %w" , err )
}
if s .Group == nil {
return fmt .Errorf ("unable to encode channels.setDiscussionGroup#40582bb2: field group is nil" )
}
if err := s .Group .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.setDiscussionGroup#40582bb2: field group: %w" , err )
}
return nil
}
func (s *ChannelsSetDiscussionGroupRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode channels.setDiscussionGroup#40582bb2 to nil" )
}
if err := b .ConsumeID (ChannelsSetDiscussionGroupRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.setDiscussionGroup#40582bb2: %w" , err )
}
return s .DecodeBare (b )
}
func (s *ChannelsSetDiscussionGroupRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode channels.setDiscussionGroup#40582bb2 to nil" )
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.setDiscussionGroup#40582bb2: field broadcast: %w" , err )
}
s .Broadcast = value
}
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.setDiscussionGroup#40582bb2: field group: %w" , err )
}
s .Group = value
}
return nil
}
func (s *ChannelsSetDiscussionGroupRequest ) GetBroadcast () (value InputChannelClass ) {
if s == nil {
return
}
return s .Broadcast
}
func (s *ChannelsSetDiscussionGroupRequest ) GetGroup () (value InputChannelClass ) {
if s == nil {
return
}
return s .Group
}
func (s *ChannelsSetDiscussionGroupRequest ) GetBroadcastAsNotEmpty () (NotEmptyInputChannel , bool ) {
return s .Broadcast .AsNotEmpty ()
}
func (s *ChannelsSetDiscussionGroupRequest ) GetGroupAsNotEmpty () (NotEmptyInputChannel , bool ) {
return s .Group .AsNotEmpty ()
}
func (c *Client ) ChannelsSetDiscussionGroup (ctx context .Context , request *ChannelsSetDiscussionGroupRequest ) (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 .