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 EncryptedMessage struct {
RandomID int64
ChatID int
Date int
Bytes []byte
File EncryptedFileClass
}
const EncryptedMessageTypeID = 0xed18c118
func (e EncryptedMessage ) construct () EncryptedMessageClass { return &e }
var (
_ bin .Encoder = &EncryptedMessage {}
_ bin .Decoder = &EncryptedMessage {}
_ bin .BareEncoder = &EncryptedMessage {}
_ bin .BareDecoder = &EncryptedMessage {}
_ EncryptedMessageClass = &EncryptedMessage {}
)
func (e *EncryptedMessage ) Zero () bool {
if e == nil {
return true
}
if !(e .RandomID == 0 ) {
return false
}
if !(e .ChatID == 0 ) {
return false
}
if !(e .Date == 0 ) {
return false
}
if !(e .Bytes == nil ) {
return false
}
if !(e .File == nil ) {
return false
}
return true
}
func (e *EncryptedMessage ) String () string {
if e == nil {
return "EncryptedMessage(nil)"
}
type Alias EncryptedMessage
return fmt .Sprintf ("EncryptedMessage%+v" , Alias (*e ))
}
func (e *EncryptedMessage ) FillFrom (from interface {
GetRandomID () (value int64 )
GetChatID () (value int )
GetDate () (value int )
GetBytes () (value []byte )
GetFile () (value EncryptedFileClass )
}) {
e .RandomID = from .GetRandomID ()
e .ChatID = from .GetChatID ()
e .Date = from .GetDate ()
e .Bytes = from .GetBytes ()
e .File = from .GetFile ()
}
func (*EncryptedMessage ) TypeID () uint32 {
return EncryptedMessageTypeID
}
func (*EncryptedMessage ) TypeName () string {
return "encryptedMessage"
}
func (e *EncryptedMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "encryptedMessage" ,
ID : EncryptedMessageTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
{
Name : "File" ,
SchemaName : "file" ,
},
}
return typ
}
func (e *EncryptedMessage ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedMessage#ed18c118 as nil" )
}
b .PutID (EncryptedMessageTypeID )
return e .EncodeBare (b )
}
func (e *EncryptedMessage ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedMessage#ed18c118 as nil" )
}
b .PutLong (e .RandomID )
b .PutInt (e .ChatID )
b .PutInt (e .Date )
b .PutBytes (e .Bytes )
if e .File == nil {
return fmt .Errorf ("unable to encode encryptedMessage#ed18c118: field file is nil" )
}
if err := e .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode encryptedMessage#ed18c118: field file: %w" , err )
}
return nil
}
func (e *EncryptedMessage ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedMessage#ed18c118 to nil" )
}
if err := b .ConsumeID (EncryptedMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EncryptedMessage ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedMessage#ed18c118 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: field random_id: %w" , err )
}
e .RandomID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: field chat_id: %w" , err )
}
e .ChatID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: field date: %w" , err )
}
e .Date = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: field bytes: %w" , err )
}
e .Bytes = value
}
{
value , err := DecodeEncryptedFile (b )
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessage#ed18c118: field file: %w" , err )
}
e .File = value
}
return nil
}
func (e *EncryptedMessage ) GetRandomID () (value int64 ) {
if e == nil {
return
}
return e .RandomID
}
func (e *EncryptedMessage ) GetChatID () (value int ) {
if e == nil {
return
}
return e .ChatID
}
func (e *EncryptedMessage ) GetDate () (value int ) {
if e == nil {
return
}
return e .Date
}
func (e *EncryptedMessage ) GetBytes () (value []byte ) {
if e == nil {
return
}
return e .Bytes
}
func (e *EncryptedMessage ) GetFile () (value EncryptedFileClass ) {
if e == nil {
return
}
return e .File
}
type EncryptedMessageService struct {
RandomID int64
ChatID int
Date int
Bytes []byte
}
const EncryptedMessageServiceTypeID = 0x23734b06
func (e EncryptedMessageService ) construct () EncryptedMessageClass { return &e }
var (
_ bin .Encoder = &EncryptedMessageService {}
_ bin .Decoder = &EncryptedMessageService {}
_ bin .BareEncoder = &EncryptedMessageService {}
_ bin .BareDecoder = &EncryptedMessageService {}
_ EncryptedMessageClass = &EncryptedMessageService {}
)
func (e *EncryptedMessageService ) Zero () bool {
if e == nil {
return true
}
if !(e .RandomID == 0 ) {
return false
}
if !(e .ChatID == 0 ) {
return false
}
if !(e .Date == 0 ) {
return false
}
if !(e .Bytes == nil ) {
return false
}
return true
}
func (e *EncryptedMessageService ) String () string {
if e == nil {
return "EncryptedMessageService(nil)"
}
type Alias EncryptedMessageService
return fmt .Sprintf ("EncryptedMessageService%+v" , Alias (*e ))
}
func (e *EncryptedMessageService ) FillFrom (from interface {
GetRandomID () (value int64 )
GetChatID () (value int )
GetDate () (value int )
GetBytes () (value []byte )
}) {
e .RandomID = from .GetRandomID ()
e .ChatID = from .GetChatID ()
e .Date = from .GetDate ()
e .Bytes = from .GetBytes ()
}
func (*EncryptedMessageService ) TypeID () uint32 {
return EncryptedMessageServiceTypeID
}
func (*EncryptedMessageService ) TypeName () string {
return "encryptedMessageService"
}
func (e *EncryptedMessageService ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "encryptedMessageService" ,
ID : EncryptedMessageServiceTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (e *EncryptedMessageService ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedMessageService#23734b06 as nil" )
}
b .PutID (EncryptedMessageServiceTypeID )
return e .EncodeBare (b )
}
func (e *EncryptedMessageService ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode encryptedMessageService#23734b06 as nil" )
}
b .PutLong (e .RandomID )
b .PutInt (e .ChatID )
b .PutInt (e .Date )
b .PutBytes (e .Bytes )
return nil
}
func (e *EncryptedMessageService ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedMessageService#23734b06 to nil" )
}
if err := b .ConsumeID (EncryptedMessageServiceTypeID ); err != nil {
return fmt .Errorf ("unable to decode encryptedMessageService#23734b06: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EncryptedMessageService ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode encryptedMessageService#23734b06 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessageService#23734b06: field random_id: %w" , err )
}
e .RandomID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessageService#23734b06: field chat_id: %w" , err )
}
e .ChatID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessageService#23734b06: field date: %w" , err )
}
e .Date = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode encryptedMessageService#23734b06: field bytes: %w" , err )
}
e .Bytes = value
}
return nil
}
func (e *EncryptedMessageService ) GetRandomID () (value int64 ) {
if e == nil {
return
}
return e .RandomID
}
func (e *EncryptedMessageService ) GetChatID () (value int ) {
if e == nil {
return
}
return e .ChatID
}
func (e *EncryptedMessageService ) GetDate () (value int ) {
if e == nil {
return
}
return e .Date
}
func (e *EncryptedMessageService ) GetBytes () (value []byte ) {
if e == nil {
return
}
return e .Bytes
}
const EncryptedMessageClassName = "EncryptedMessage"
type EncryptedMessageClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () EncryptedMessageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetRandomID () (value int64 )
GetChatID () (value int )
GetDate () (value int )
GetBytes () (value []byte )
}
func DecodeEncryptedMessage (buf *bin .Buffer ) (EncryptedMessageClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case EncryptedMessageTypeID :
v := EncryptedMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EncryptedMessageClass: %w" , err )
}
return &v , nil
case EncryptedMessageServiceTypeID :
v := EncryptedMessageService {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EncryptedMessageClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode EncryptedMessageClass: %w" , bin .NewUnexpectedID (id ))
}
}
type EncryptedMessageBox struct {
EncryptedMessage EncryptedMessageClass
}
func (b *EncryptedMessageBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode EncryptedMessageBox to nil" )
}
v , err := DecodeEncryptedMessage (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .EncryptedMessage = v
return nil
}
func (b *EncryptedMessageBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .EncryptedMessage == nil {
return fmt .Errorf ("unable to encode EncryptedMessageClass as nil" )
}
return b .EncryptedMessage .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 .