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 ReactionEmpty struct {
}
const ReactionEmptyTypeID = 0x79f5d419
func (r ReactionEmpty ) construct () ReactionClass { return &r }
var (
_ bin .Encoder = &ReactionEmpty {}
_ bin .Decoder = &ReactionEmpty {}
_ bin .BareEncoder = &ReactionEmpty {}
_ bin .BareDecoder = &ReactionEmpty {}
_ ReactionClass = &ReactionEmpty {}
)
func (r *ReactionEmpty ) Zero () bool {
if r == nil {
return true
}
return true
}
func (r *ReactionEmpty ) String () string {
if r == nil {
return "ReactionEmpty(nil)"
}
type Alias ReactionEmpty
return fmt .Sprintf ("ReactionEmpty%+v" , Alias (*r ))
}
func (*ReactionEmpty ) TypeID () uint32 {
return ReactionEmptyTypeID
}
func (*ReactionEmpty ) TypeName () string {
return "reactionEmpty"
}
func (r *ReactionEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reactionEmpty" ,
ID : ReactionEmptyTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (r *ReactionEmpty ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionEmpty#79f5d419 as nil" )
}
b .PutID (ReactionEmptyTypeID )
return r .EncodeBare (b )
}
func (r *ReactionEmpty ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionEmpty#79f5d419 as nil" )
}
return nil
}
func (r *ReactionEmpty ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionEmpty#79f5d419 to nil" )
}
if err := b .ConsumeID (ReactionEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode reactionEmpty#79f5d419: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReactionEmpty ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionEmpty#79f5d419 to nil" )
}
return nil
}
type ReactionEmoji struct {
Emoticon string
}
const ReactionEmojiTypeID = 0x1b2286b8
func (r ReactionEmoji ) construct () ReactionClass { return &r }
var (
_ bin .Encoder = &ReactionEmoji {}
_ bin .Decoder = &ReactionEmoji {}
_ bin .BareEncoder = &ReactionEmoji {}
_ bin .BareDecoder = &ReactionEmoji {}
_ ReactionClass = &ReactionEmoji {}
)
func (r *ReactionEmoji ) Zero () bool {
if r == nil {
return true
}
if !(r .Emoticon == "" ) {
return false
}
return true
}
func (r *ReactionEmoji ) String () string {
if r == nil {
return "ReactionEmoji(nil)"
}
type Alias ReactionEmoji
return fmt .Sprintf ("ReactionEmoji%+v" , Alias (*r ))
}
func (r *ReactionEmoji ) FillFrom (from interface {
GetEmoticon () (value string )
}) {
r .Emoticon = from .GetEmoticon ()
}
func (*ReactionEmoji ) TypeID () uint32 {
return ReactionEmojiTypeID
}
func (*ReactionEmoji ) TypeName () string {
return "reactionEmoji"
}
func (r *ReactionEmoji ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reactionEmoji" ,
ID : ReactionEmojiTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
},
}
return typ
}
func (r *ReactionEmoji ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionEmoji#1b2286b8 as nil" )
}
b .PutID (ReactionEmojiTypeID )
return r .EncodeBare (b )
}
func (r *ReactionEmoji ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionEmoji#1b2286b8 as nil" )
}
b .PutString (r .Emoticon )
return nil
}
func (r *ReactionEmoji ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionEmoji#1b2286b8 to nil" )
}
if err := b .ConsumeID (ReactionEmojiTypeID ); err != nil {
return fmt .Errorf ("unable to decode reactionEmoji#1b2286b8: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReactionEmoji ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionEmoji#1b2286b8 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode reactionEmoji#1b2286b8: field emoticon: %w" , err )
}
r .Emoticon = value
}
return nil
}
func (r *ReactionEmoji ) GetEmoticon () (value string ) {
if r == nil {
return
}
return r .Emoticon
}
type ReactionCustomEmoji struct {
DocumentID int64
}
const ReactionCustomEmojiTypeID = 0x8935fc73
func (r ReactionCustomEmoji ) construct () ReactionClass { return &r }
var (
_ bin .Encoder = &ReactionCustomEmoji {}
_ bin .Decoder = &ReactionCustomEmoji {}
_ bin .BareEncoder = &ReactionCustomEmoji {}
_ bin .BareDecoder = &ReactionCustomEmoji {}
_ ReactionClass = &ReactionCustomEmoji {}
)
func (r *ReactionCustomEmoji ) Zero () bool {
if r == nil {
return true
}
if !(r .DocumentID == 0 ) {
return false
}
return true
}
func (r *ReactionCustomEmoji ) String () string {
if r == nil {
return "ReactionCustomEmoji(nil)"
}
type Alias ReactionCustomEmoji
return fmt .Sprintf ("ReactionCustomEmoji%+v" , Alias (*r ))
}
func (r *ReactionCustomEmoji ) FillFrom (from interface {
GetDocumentID () (value int64 )
}) {
r .DocumentID = from .GetDocumentID ()
}
func (*ReactionCustomEmoji ) TypeID () uint32 {
return ReactionCustomEmojiTypeID
}
func (*ReactionCustomEmoji ) TypeName () string {
return "reactionCustomEmoji"
}
func (r *ReactionCustomEmoji ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reactionCustomEmoji" ,
ID : ReactionCustomEmojiTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "DocumentID" ,
SchemaName : "document_id" ,
},
}
return typ
}
func (r *ReactionCustomEmoji ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionCustomEmoji#8935fc73 as nil" )
}
b .PutID (ReactionCustomEmojiTypeID )
return r .EncodeBare (b )
}
func (r *ReactionCustomEmoji ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionCustomEmoji#8935fc73 as nil" )
}
b .PutLong (r .DocumentID )
return nil
}
func (r *ReactionCustomEmoji ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionCustomEmoji#8935fc73 to nil" )
}
if err := b .ConsumeID (ReactionCustomEmojiTypeID ); err != nil {
return fmt .Errorf ("unable to decode reactionCustomEmoji#8935fc73: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReactionCustomEmoji ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionCustomEmoji#8935fc73 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode reactionCustomEmoji#8935fc73: field document_id: %w" , err )
}
r .DocumentID = value
}
return nil
}
func (r *ReactionCustomEmoji ) GetDocumentID () (value int64 ) {
if r == nil {
return
}
return r .DocumentID
}
const ReactionClassName = "Reaction"
type ReactionClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ReactionClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeReaction (buf *bin .Buffer ) (ReactionClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ReactionEmptyTypeID :
v := ReactionEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReactionClass: %w" , err )
}
return &v , nil
case ReactionEmojiTypeID :
v := ReactionEmoji {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReactionClass: %w" , err )
}
return &v , nil
case ReactionCustomEmojiTypeID :
v := ReactionCustomEmoji {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ReactionClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ReactionClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ReactionBox struct {
Reaction ReactionClass
}
func (b *ReactionBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ReactionBox to nil" )
}
v , err := DecodeReaction (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Reaction = v
return nil
}
func (b *ReactionBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Reaction == nil {
return fmt .Errorf ("unable to encode ReactionClass as nil" )
}
return b .Reaction .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 .