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 InputChannelEmpty struct {
}
const InputChannelEmptyTypeID = 0xee8c1e86
func (i InputChannelEmpty ) construct () InputChannelClass { return &i }
var (
_ bin .Encoder = &InputChannelEmpty {}
_ bin .Decoder = &InputChannelEmpty {}
_ bin .BareEncoder = &InputChannelEmpty {}
_ bin .BareDecoder = &InputChannelEmpty {}
_ InputChannelClass = &InputChannelEmpty {}
)
func (i *InputChannelEmpty ) Zero () bool {
if i == nil {
return true
}
return true
}
func (i *InputChannelEmpty ) String () string {
if i == nil {
return "InputChannelEmpty(nil)"
}
type Alias InputChannelEmpty
return fmt .Sprintf ("InputChannelEmpty%+v" , Alias (*i ))
}
func (*InputChannelEmpty ) TypeID () uint32 {
return InputChannelEmptyTypeID
}
func (*InputChannelEmpty ) TypeName () string {
return "inputChannelEmpty"
}
func (i *InputChannelEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputChannelEmpty" ,
ID : InputChannelEmptyTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (i *InputChannelEmpty ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannelEmpty#ee8c1e86 as nil" )
}
b .PutID (InputChannelEmptyTypeID )
return i .EncodeBare (b )
}
func (i *InputChannelEmpty ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannelEmpty#ee8c1e86 as nil" )
}
return nil
}
func (i *InputChannelEmpty ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannelEmpty#ee8c1e86 to nil" )
}
if err := b .ConsumeID (InputChannelEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputChannelEmpty#ee8c1e86: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputChannelEmpty ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannelEmpty#ee8c1e86 to nil" )
}
return nil
}
type InputChannel struct {
ChannelID int64
AccessHash int64
}
const InputChannelTypeID = 0xf35aec28
func (i InputChannel ) construct () InputChannelClass { return &i }
var (
_ bin .Encoder = &InputChannel {}
_ bin .Decoder = &InputChannel {}
_ bin .BareEncoder = &InputChannel {}
_ bin .BareDecoder = &InputChannel {}
_ InputChannelClass = &InputChannel {}
)
func (i *InputChannel ) Zero () bool {
if i == nil {
return true
}
if !(i .ChannelID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
return true
}
func (i *InputChannel ) String () string {
if i == nil {
return "InputChannel(nil)"
}
type Alias InputChannel
return fmt .Sprintf ("InputChannel%+v" , Alias (*i ))
}
func (i *InputChannel ) FillFrom (from interface {
GetChannelID () (value int64 )
GetAccessHash () (value int64 )
}) {
i .ChannelID = from .GetChannelID ()
i .AccessHash = from .GetAccessHash ()
}
func (*InputChannel ) TypeID () uint32 {
return InputChannelTypeID
}
func (*InputChannel ) TypeName () string {
return "inputChannel"
}
func (i *InputChannel ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputChannel" ,
ID : InputChannelTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChannelID" ,
SchemaName : "channel_id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
}
return typ
}
func (i *InputChannel ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannel#f35aec28 as nil" )
}
b .PutID (InputChannelTypeID )
return i .EncodeBare (b )
}
func (i *InputChannel ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannel#f35aec28 as nil" )
}
b .PutLong (i .ChannelID )
b .PutLong (i .AccessHash )
return nil
}
func (i *InputChannel ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannel#f35aec28 to nil" )
}
if err := b .ConsumeID (InputChannelTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputChannel#f35aec28: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputChannel ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannel#f35aec28 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputChannel#f35aec28: field channel_id: %w" , err )
}
i .ChannelID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputChannel#f35aec28: field access_hash: %w" , err )
}
i .AccessHash = value
}
return nil
}
func (i *InputChannel ) GetChannelID () (value int64 ) {
if i == nil {
return
}
return i .ChannelID
}
func (i *InputChannel ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
type InputChannelFromMessage struct {
Peer InputPeerClass
MsgID int
ChannelID int64
}
const InputChannelFromMessageTypeID = 0x5b934f9d
func (i InputChannelFromMessage ) construct () InputChannelClass { return &i }
var (
_ bin .Encoder = &InputChannelFromMessage {}
_ bin .Decoder = &InputChannelFromMessage {}
_ bin .BareEncoder = &InputChannelFromMessage {}
_ bin .BareDecoder = &InputChannelFromMessage {}
_ InputChannelClass = &InputChannelFromMessage {}
)
func (i *InputChannelFromMessage ) Zero () bool {
if i == nil {
return true
}
if !(i .Peer == nil ) {
return false
}
if !(i .MsgID == 0 ) {
return false
}
if !(i .ChannelID == 0 ) {
return false
}
return true
}
func (i *InputChannelFromMessage ) String () string {
if i == nil {
return "InputChannelFromMessage(nil)"
}
type Alias InputChannelFromMessage
return fmt .Sprintf ("InputChannelFromMessage%+v" , Alias (*i ))
}
func (i *InputChannelFromMessage ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetMsgID () (value int )
GetChannelID () (value int64 )
}) {
i .Peer = from .GetPeer ()
i .MsgID = from .GetMsgID ()
i .ChannelID = from .GetChannelID ()
}
func (*InputChannelFromMessage ) TypeID () uint32 {
return InputChannelFromMessageTypeID
}
func (*InputChannelFromMessage ) TypeName () string {
return "inputChannelFromMessage"
}
func (i *InputChannelFromMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputChannelFromMessage" ,
ID : InputChannelFromMessageTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "ChannelID" ,
SchemaName : "channel_id" ,
},
}
return typ
}
func (i *InputChannelFromMessage ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannelFromMessage#5b934f9d as nil" )
}
b .PutID (InputChannelFromMessageTypeID )
return i .EncodeBare (b )
}
func (i *InputChannelFromMessage ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputChannelFromMessage#5b934f9d as nil" )
}
if i .Peer == nil {
return fmt .Errorf ("unable to encode inputChannelFromMessage#5b934f9d: field peer is nil" )
}
if err := i .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputChannelFromMessage#5b934f9d: field peer: %w" , err )
}
b .PutInt (i .MsgID )
b .PutLong (i .ChannelID )
return nil
}
func (i *InputChannelFromMessage ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannelFromMessage#5b934f9d to nil" )
}
if err := b .ConsumeID (InputChannelFromMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputChannelFromMessage#5b934f9d: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputChannelFromMessage ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputChannelFromMessage#5b934f9d to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputChannelFromMessage#5b934f9d: field peer: %w" , err )
}
i .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputChannelFromMessage#5b934f9d: field msg_id: %w" , err )
}
i .MsgID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputChannelFromMessage#5b934f9d: field channel_id: %w" , err )
}
i .ChannelID = value
}
return nil
}
func (i *InputChannelFromMessage ) GetPeer () (value InputPeerClass ) {
if i == nil {
return
}
return i .Peer
}
func (i *InputChannelFromMessage ) GetMsgID () (value int ) {
if i == nil {
return
}
return i .MsgID
}
func (i *InputChannelFromMessage ) GetChannelID () (value int64 ) {
if i == nil {
return
}
return i .ChannelID
}
const InputChannelClassName = "InputChannel"
type InputChannelClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputChannelClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (NotEmptyInputChannel , bool )
}
type NotEmptyInputChannel interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputChannelClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetChannelID () (value int64 )
}
func (i *InputChannelEmpty ) AsNotEmpty () (NotEmptyInputChannel , bool ) {
value , ok := (InputChannelClass (i )).(NotEmptyInputChannel )
return value , ok
}
func (i *InputChannel ) AsNotEmpty () (NotEmptyInputChannel , bool ) {
value , ok := (InputChannelClass (i )).(NotEmptyInputChannel )
return value , ok
}
func (i *InputChannelFromMessage ) AsNotEmpty () (NotEmptyInputChannel , bool ) {
value , ok := (InputChannelClass (i )).(NotEmptyInputChannel )
return value , ok
}
func DecodeInputChannel (buf *bin .Buffer ) (InputChannelClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputChannelEmptyTypeID :
v := InputChannelEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputChannelClass: %w" , err )
}
return &v , nil
case InputChannelTypeID :
v := InputChannel {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputChannelClass: %w" , err )
}
return &v , nil
case InputChannelFromMessageTypeID :
v := InputChannelFromMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputChannelClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputChannelClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputChannelBox struct {
InputChannel InputChannelClass
}
func (b *InputChannelBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputChannelBox to nil" )
}
v , err := DecodeInputChannel (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputChannel = v
return nil
}
func (b *InputChannelBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputChannel == nil {
return fmt .Errorf ("unable to encode InputChannelClass as nil" )
}
return b .InputChannel .Encode (buf )
}
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 .