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 EmojiKeyword struct {
Keyword string
Emoticons []string
}
const EmojiKeywordTypeID = 0xd5b3b9f9
func (e EmojiKeyword ) construct () EmojiKeywordClass { return &e }
var (
_ bin .Encoder = &EmojiKeyword {}
_ bin .Decoder = &EmojiKeyword {}
_ bin .BareEncoder = &EmojiKeyword {}
_ bin .BareDecoder = &EmojiKeyword {}
_ EmojiKeywordClass = &EmojiKeyword {}
)
func (e *EmojiKeyword ) Zero () bool {
if e == nil {
return true
}
if !(e .Keyword == "" ) {
return false
}
if !(e .Emoticons == nil ) {
return false
}
return true
}
func (e *EmojiKeyword ) String () string {
if e == nil {
return "EmojiKeyword(nil)"
}
type Alias EmojiKeyword
return fmt .Sprintf ("EmojiKeyword%+v" , Alias (*e ))
}
func (e *EmojiKeyword ) FillFrom (from interface {
GetKeyword () (value string )
GetEmoticons () (value []string )
}) {
e .Keyword = from .GetKeyword ()
e .Emoticons = from .GetEmoticons ()
}
func (*EmojiKeyword ) TypeID () uint32 {
return EmojiKeywordTypeID
}
func (*EmojiKeyword ) TypeName () string {
return "emojiKeyword"
}
func (e *EmojiKeyword ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emojiKeyword" ,
ID : EmojiKeywordTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Keyword" ,
SchemaName : "keyword" ,
},
{
Name : "Emoticons" ,
SchemaName : "emoticons" ,
},
}
return typ
}
func (e *EmojiKeyword ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emojiKeyword#d5b3b9f9 as nil" )
}
b .PutID (EmojiKeywordTypeID )
return e .EncodeBare (b )
}
func (e *EmojiKeyword ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emojiKeyword#d5b3b9f9 as nil" )
}
b .PutString (e .Keyword )
b .PutVectorHeader (len (e .Emoticons ))
for _ , v := range e .Emoticons {
b .PutString (v )
}
return nil
}
func (e *EmojiKeyword ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emojiKeyword#d5b3b9f9 to nil" )
}
if err := b .ConsumeID (EmojiKeywordTypeID ); err != nil {
return fmt .Errorf ("unable to decode emojiKeyword#d5b3b9f9: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmojiKeyword ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emojiKeyword#d5b3b9f9 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeyword#d5b3b9f9: field keyword: %w" , err )
}
e .Keyword = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeyword#d5b3b9f9: field emoticons: %w" , err )
}
if headerLen > 0 {
e .Emoticons = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeyword#d5b3b9f9: field emoticons: %w" , err )
}
e .Emoticons = append (e .Emoticons , value )
}
}
return nil
}
func (e *EmojiKeyword ) GetKeyword () (value string ) {
if e == nil {
return
}
return e .Keyword
}
func (e *EmojiKeyword ) GetEmoticons () (value []string ) {
if e == nil {
return
}
return e .Emoticons
}
type EmojiKeywordDeleted struct {
Keyword string
Emoticons []string
}
const EmojiKeywordDeletedTypeID = 0x236df622
func (e EmojiKeywordDeleted ) construct () EmojiKeywordClass { return &e }
var (
_ bin .Encoder = &EmojiKeywordDeleted {}
_ bin .Decoder = &EmojiKeywordDeleted {}
_ bin .BareEncoder = &EmojiKeywordDeleted {}
_ bin .BareDecoder = &EmojiKeywordDeleted {}
_ EmojiKeywordClass = &EmojiKeywordDeleted {}
)
func (e *EmojiKeywordDeleted ) Zero () bool {
if e == nil {
return true
}
if !(e .Keyword == "" ) {
return false
}
if !(e .Emoticons == nil ) {
return false
}
return true
}
func (e *EmojiKeywordDeleted ) String () string {
if e == nil {
return "EmojiKeywordDeleted(nil)"
}
type Alias EmojiKeywordDeleted
return fmt .Sprintf ("EmojiKeywordDeleted%+v" , Alias (*e ))
}
func (e *EmojiKeywordDeleted ) FillFrom (from interface {
GetKeyword () (value string )
GetEmoticons () (value []string )
}) {
e .Keyword = from .GetKeyword ()
e .Emoticons = from .GetEmoticons ()
}
func (*EmojiKeywordDeleted ) TypeID () uint32 {
return EmojiKeywordDeletedTypeID
}
func (*EmojiKeywordDeleted ) TypeName () string {
return "emojiKeywordDeleted"
}
func (e *EmojiKeywordDeleted ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emojiKeywordDeleted" ,
ID : EmojiKeywordDeletedTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Keyword" ,
SchemaName : "keyword" ,
},
{
Name : "Emoticons" ,
SchemaName : "emoticons" ,
},
}
return typ
}
func (e *EmojiKeywordDeleted ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emojiKeywordDeleted#236df622 as nil" )
}
b .PutID (EmojiKeywordDeletedTypeID )
return e .EncodeBare (b )
}
func (e *EmojiKeywordDeleted ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emojiKeywordDeleted#236df622 as nil" )
}
b .PutString (e .Keyword )
b .PutVectorHeader (len (e .Emoticons ))
for _ , v := range e .Emoticons {
b .PutString (v )
}
return nil
}
func (e *EmojiKeywordDeleted ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emojiKeywordDeleted#236df622 to nil" )
}
if err := b .ConsumeID (EmojiKeywordDeletedTypeID ); err != nil {
return fmt .Errorf ("unable to decode emojiKeywordDeleted#236df622: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmojiKeywordDeleted ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emojiKeywordDeleted#236df622 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeywordDeleted#236df622: field keyword: %w" , err )
}
e .Keyword = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeywordDeleted#236df622: field emoticons: %w" , err )
}
if headerLen > 0 {
e .Emoticons = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emojiKeywordDeleted#236df622: field emoticons: %w" , err )
}
e .Emoticons = append (e .Emoticons , value )
}
}
return nil
}
func (e *EmojiKeywordDeleted ) GetKeyword () (value string ) {
if e == nil {
return
}
return e .Keyword
}
func (e *EmojiKeywordDeleted ) GetEmoticons () (value []string ) {
if e == nil {
return
}
return e .Emoticons
}
const EmojiKeywordClassName = "EmojiKeyword"
type EmojiKeywordClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () EmojiKeywordClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetKeyword () (value string )
GetEmoticons () (value []string )
}
func DecodeEmojiKeyword (buf *bin .Buffer ) (EmojiKeywordClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case EmojiKeywordTypeID :
v := EmojiKeyword {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmojiKeywordClass: %w" , err )
}
return &v , nil
case EmojiKeywordDeletedTypeID :
v := EmojiKeywordDeleted {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmojiKeywordClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode EmojiKeywordClass: %w" , bin .NewUnexpectedID (id ))
}
}
type EmojiKeywordBox struct {
EmojiKeyword EmojiKeywordClass
}
func (b *EmojiKeywordBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode EmojiKeywordBox to nil" )
}
v , err := DecodeEmojiKeyword (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .EmojiKeyword = v
return nil
}
func (b *EmojiKeywordBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .EmojiKeyword == nil {
return fmt .Errorf ("unable to encode EmojiKeywordClass as nil" )
}
return b .EmojiKeyword .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 .