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 InputMessageID struct {
ID int
}
const InputMessageIDTypeID = 0xa676a322
func (i InputMessageID ) construct () InputMessageClass { return &i }
var (
_ bin .Encoder = &InputMessageID {}
_ bin .Decoder = &InputMessageID {}
_ bin .BareEncoder = &InputMessageID {}
_ bin .BareDecoder = &InputMessageID {}
_ InputMessageClass = &InputMessageID {}
)
func (i *InputMessageID ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
return true
}
func (i *InputMessageID ) String () string {
if i == nil {
return "InputMessageID(nil)"
}
type Alias InputMessageID
return fmt .Sprintf ("InputMessageID%+v" , Alias (*i ))
}
func (i *InputMessageID ) FillFrom (from interface {
GetID () (value int )
}) {
i .ID = from .GetID ()
}
func (*InputMessageID ) TypeID () uint32 {
return InputMessageIDTypeID
}
func (*InputMessageID ) TypeName () string {
return "inputMessageID"
}
func (i *InputMessageID ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputMessageID" ,
ID : InputMessageIDTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (i *InputMessageID ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageID#a676a322 as nil" )
}
b .PutID (InputMessageIDTypeID )
return i .EncodeBare (b )
}
func (i *InputMessageID ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageID#a676a322 as nil" )
}
b .PutInt (i .ID )
return nil
}
func (i *InputMessageID ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageID#a676a322 to nil" )
}
if err := b .ConsumeID (InputMessageIDTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputMessageID#a676a322: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputMessageID ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageID#a676a322 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputMessageID#a676a322: field id: %w" , err )
}
i .ID = value
}
return nil
}
func (i *InputMessageID ) GetID () (value int ) {
if i == nil {
return
}
return i .ID
}
type InputMessageReplyTo struct {
ID int
}
const InputMessageReplyToTypeID = 0xbad88395
func (i InputMessageReplyTo ) construct () InputMessageClass { return &i }
var (
_ bin .Encoder = &InputMessageReplyTo {}
_ bin .Decoder = &InputMessageReplyTo {}
_ bin .BareEncoder = &InputMessageReplyTo {}
_ bin .BareDecoder = &InputMessageReplyTo {}
_ InputMessageClass = &InputMessageReplyTo {}
)
func (i *InputMessageReplyTo ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
return true
}
func (i *InputMessageReplyTo ) String () string {
if i == nil {
return "InputMessageReplyTo(nil)"
}
type Alias InputMessageReplyTo
return fmt .Sprintf ("InputMessageReplyTo%+v" , Alias (*i ))
}
func (i *InputMessageReplyTo ) FillFrom (from interface {
GetID () (value int )
}) {
i .ID = from .GetID ()
}
func (*InputMessageReplyTo ) TypeID () uint32 {
return InputMessageReplyToTypeID
}
func (*InputMessageReplyTo ) TypeName () string {
return "inputMessageReplyTo"
}
func (i *InputMessageReplyTo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputMessageReplyTo" ,
ID : InputMessageReplyToTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (i *InputMessageReplyTo ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageReplyTo#bad88395 as nil" )
}
b .PutID (InputMessageReplyToTypeID )
return i .EncodeBare (b )
}
func (i *InputMessageReplyTo ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageReplyTo#bad88395 as nil" )
}
b .PutInt (i .ID )
return nil
}
func (i *InputMessageReplyTo ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageReplyTo#bad88395 to nil" )
}
if err := b .ConsumeID (InputMessageReplyToTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputMessageReplyTo#bad88395: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputMessageReplyTo ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageReplyTo#bad88395 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputMessageReplyTo#bad88395: field id: %w" , err )
}
i .ID = value
}
return nil
}
func (i *InputMessageReplyTo ) GetID () (value int ) {
if i == nil {
return
}
return i .ID
}
type InputMessagePinned struct {
}
const InputMessagePinnedTypeID = 0x86872538
func (i InputMessagePinned ) construct () InputMessageClass { return &i }
var (
_ bin .Encoder = &InputMessagePinned {}
_ bin .Decoder = &InputMessagePinned {}
_ bin .BareEncoder = &InputMessagePinned {}
_ bin .BareDecoder = &InputMessagePinned {}
_ InputMessageClass = &InputMessagePinned {}
)
func (i *InputMessagePinned ) Zero () bool {
if i == nil {
return true
}
return true
}
func (i *InputMessagePinned ) String () string {
if i == nil {
return "InputMessagePinned(nil)"
}
type Alias InputMessagePinned
return fmt .Sprintf ("InputMessagePinned%+v" , Alias (*i ))
}
func (*InputMessagePinned ) TypeID () uint32 {
return InputMessagePinnedTypeID
}
func (*InputMessagePinned ) TypeName () string {
return "inputMessagePinned"
}
func (i *InputMessagePinned ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputMessagePinned" ,
ID : InputMessagePinnedTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (i *InputMessagePinned ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessagePinned#86872538 as nil" )
}
b .PutID (InputMessagePinnedTypeID )
return i .EncodeBare (b )
}
func (i *InputMessagePinned ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessagePinned#86872538 as nil" )
}
return nil
}
func (i *InputMessagePinned ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessagePinned#86872538 to nil" )
}
if err := b .ConsumeID (InputMessagePinnedTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputMessagePinned#86872538: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputMessagePinned ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessagePinned#86872538 to nil" )
}
return nil
}
type InputMessageCallbackQuery struct {
ID int
QueryID int64
}
const InputMessageCallbackQueryTypeID = 0xacfa1a7e
func (i InputMessageCallbackQuery ) construct () InputMessageClass { return &i }
var (
_ bin .Encoder = &InputMessageCallbackQuery {}
_ bin .Decoder = &InputMessageCallbackQuery {}
_ bin .BareEncoder = &InputMessageCallbackQuery {}
_ bin .BareDecoder = &InputMessageCallbackQuery {}
_ InputMessageClass = &InputMessageCallbackQuery {}
)
func (i *InputMessageCallbackQuery ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .QueryID == 0 ) {
return false
}
return true
}
func (i *InputMessageCallbackQuery ) String () string {
if i == nil {
return "InputMessageCallbackQuery(nil)"
}
type Alias InputMessageCallbackQuery
return fmt .Sprintf ("InputMessageCallbackQuery%+v" , Alias (*i ))
}
func (i *InputMessageCallbackQuery ) FillFrom (from interface {
GetID () (value int )
GetQueryID () (value int64 )
}) {
i .ID = from .GetID ()
i .QueryID = from .GetQueryID ()
}
func (*InputMessageCallbackQuery ) TypeID () uint32 {
return InputMessageCallbackQueryTypeID
}
func (*InputMessageCallbackQuery ) TypeName () string {
return "inputMessageCallbackQuery"
}
func (i *InputMessageCallbackQuery ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputMessageCallbackQuery" ,
ID : InputMessageCallbackQueryTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "QueryID" ,
SchemaName : "query_id" ,
},
}
return typ
}
func (i *InputMessageCallbackQuery ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageCallbackQuery#acfa1a7e as nil" )
}
b .PutID (InputMessageCallbackQueryTypeID )
return i .EncodeBare (b )
}
func (i *InputMessageCallbackQuery ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputMessageCallbackQuery#acfa1a7e as nil" )
}
b .PutInt (i .ID )
b .PutLong (i .QueryID )
return nil
}
func (i *InputMessageCallbackQuery ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageCallbackQuery#acfa1a7e to nil" )
}
if err := b .ConsumeID (InputMessageCallbackQueryTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputMessageCallbackQuery#acfa1a7e: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputMessageCallbackQuery ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputMessageCallbackQuery#acfa1a7e to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputMessageCallbackQuery#acfa1a7e: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputMessageCallbackQuery#acfa1a7e: field query_id: %w" , err )
}
i .QueryID = value
}
return nil
}
func (i *InputMessageCallbackQuery ) GetID () (value int ) {
if i == nil {
return
}
return i .ID
}
func (i *InputMessageCallbackQuery ) GetQueryID () (value int64 ) {
if i == nil {
return
}
return i .QueryID
}
const InputMessageClassName = "InputMessage"
type InputMessageClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputMessageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputMessage (buf *bin .Buffer ) (InputMessageClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputMessageIDTypeID :
v := InputMessageID {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputMessageClass: %w" , err )
}
return &v , nil
case InputMessageReplyToTypeID :
v := InputMessageReplyTo {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputMessageClass: %w" , err )
}
return &v , nil
case InputMessagePinnedTypeID :
v := InputMessagePinned {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputMessageClass: %w" , err )
}
return &v , nil
case InputMessageCallbackQueryTypeID :
v := InputMessageCallbackQuery {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputMessageClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputMessageClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputMessageBox struct {
InputMessage InputMessageClass
}
func (b *InputMessageBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputMessageBox to nil" )
}
v , err := DecodeInputMessage (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputMessage = v
return nil
}
func (b *InputMessageBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputMessage == nil {
return fmt .Errorf ("unable to encode InputMessageClass as nil" )
}
return b .InputMessage .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 .