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 InputReplyToMessage struct {
Flags bin .Fields
ReplyToMsgID int
TopMsgID int
ReplyToPeerID InputPeerClass
QuoteText string
QuoteEntities []MessageEntityClass
QuoteOffset int
}
const InputReplyToMessageTypeID = 0x22c0f6d5
func (i InputReplyToMessage ) construct () InputReplyToClass { return &i }
var (
_ bin .Encoder = &InputReplyToMessage {}
_ bin .Decoder = &InputReplyToMessage {}
_ bin .BareEncoder = &InputReplyToMessage {}
_ bin .BareDecoder = &InputReplyToMessage {}
_ InputReplyToClass = &InputReplyToMessage {}
)
func (i *InputReplyToMessage ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .ReplyToMsgID == 0 ) {
return false
}
if !(i .TopMsgID == 0 ) {
return false
}
if !(i .ReplyToPeerID == nil ) {
return false
}
if !(i .QuoteText == "" ) {
return false
}
if !(i .QuoteEntities == nil ) {
return false
}
if !(i .QuoteOffset == 0 ) {
return false
}
return true
}
func (i *InputReplyToMessage ) String () string {
if i == nil {
return "InputReplyToMessage(nil)"
}
type Alias InputReplyToMessage
return fmt .Sprintf ("InputReplyToMessage%+v" , Alias (*i ))
}
func (i *InputReplyToMessage ) FillFrom (from interface {
GetReplyToMsgID () (value int )
GetTopMsgID () (value int , ok bool )
GetReplyToPeerID () (value InputPeerClass , ok bool )
GetQuoteText () (value string , ok bool )
GetQuoteEntities () (value []MessageEntityClass , ok bool )
GetQuoteOffset () (value int , ok bool )
}) {
i .ReplyToMsgID = from .GetReplyToMsgID ()
if val , ok := from .GetTopMsgID (); ok {
i .TopMsgID = val
}
if val , ok := from .GetReplyToPeerID (); ok {
i .ReplyToPeerID = val
}
if val , ok := from .GetQuoteText (); ok {
i .QuoteText = val
}
if val , ok := from .GetQuoteEntities (); ok {
i .QuoteEntities = val
}
if val , ok := from .GetQuoteOffset (); ok {
i .QuoteOffset = val
}
}
func (*InputReplyToMessage ) TypeID () uint32 {
return InputReplyToMessageTypeID
}
func (*InputReplyToMessage ) TypeName () string {
return "inputReplyToMessage"
}
func (i *InputReplyToMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputReplyToMessage" ,
ID : InputReplyToMessageTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ReplyToMsgID" ,
SchemaName : "reply_to_msg_id" ,
},
{
Name : "TopMsgID" ,
SchemaName : "top_msg_id" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "ReplyToPeerID" ,
SchemaName : "reply_to_peer_id" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "QuoteText" ,
SchemaName : "quote_text" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "QuoteEntities" ,
SchemaName : "quote_entities" ,
Null : !i .Flags .Has (3 ),
},
{
Name : "QuoteOffset" ,
SchemaName : "quote_offset" ,
Null : !i .Flags .Has (4 ),
},
}
return typ
}
func (i *InputReplyToMessage ) SetFlags () {
if !(i .TopMsgID == 0 ) {
i .Flags .Set (0 )
}
if !(i .ReplyToPeerID == nil ) {
i .Flags .Set (1 )
}
if !(i .QuoteText == "" ) {
i .Flags .Set (2 )
}
if !(i .QuoteEntities == nil ) {
i .Flags .Set (3 )
}
if !(i .QuoteOffset == 0 ) {
i .Flags .Set (4 )
}
}
func (i *InputReplyToMessage ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputReplyToMessage#22c0f6d5 as nil" )
}
b .PutID (InputReplyToMessageTypeID )
return i .EncodeBare (b )
}
func (i *InputReplyToMessage ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputReplyToMessage#22c0f6d5 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputReplyToMessage#22c0f6d5: field flags: %w" , err )
}
b .PutInt (i .ReplyToMsgID )
if i .Flags .Has (0 ) {
b .PutInt (i .TopMsgID )
}
if i .Flags .Has (1 ) {
if i .ReplyToPeerID == nil {
return fmt .Errorf ("unable to encode inputReplyToMessage#22c0f6d5: field reply_to_peer_id is nil" )
}
if err := i .ReplyToPeerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputReplyToMessage#22c0f6d5: field reply_to_peer_id: %w" , err )
}
}
if i .Flags .Has (2 ) {
b .PutString (i .QuoteText )
}
if i .Flags .Has (3 ) {
b .PutVectorHeader (len (i .QuoteEntities ))
for idx , v := range i .QuoteEntities {
if v == nil {
return fmt .Errorf ("unable to encode inputReplyToMessage#22c0f6d5: field quote_entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputReplyToMessage#22c0f6d5: field quote_entities element with index %d: %w" , idx , err )
}
}
}
if i .Flags .Has (4 ) {
b .PutInt (i .QuoteOffset )
}
return nil
}
func (i *InputReplyToMessage ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputReplyToMessage#22c0f6d5 to nil" )
}
if err := b .ConsumeID (InputReplyToMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputReplyToMessage ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputReplyToMessage#22c0f6d5 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field reply_to_msg_id: %w" , err )
}
i .ReplyToMsgID = value
}
if i .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field top_msg_id: %w" , err )
}
i .TopMsgID = value
}
if i .Flags .Has (1 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field reply_to_peer_id: %w" , err )
}
i .ReplyToPeerID = value
}
if i .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field quote_text: %w" , err )
}
i .QuoteText = value
}
if i .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field quote_entities: %w" , err )
}
if headerLen > 0 {
i .QuoteEntities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field quote_entities: %w" , err )
}
i .QuoteEntities = append (i .QuoteEntities , value )
}
}
if i .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToMessage#22c0f6d5: field quote_offset: %w" , err )
}
i .QuoteOffset = value
}
return nil
}
func (i *InputReplyToMessage ) GetReplyToMsgID () (value int ) {
if i == nil {
return
}
return i .ReplyToMsgID
}
func (i *InputReplyToMessage ) SetTopMsgID (value int ) {
i .Flags .Set (0 )
i .TopMsgID = value
}
func (i *InputReplyToMessage ) GetTopMsgID () (value int , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .TopMsgID , true
}
func (i *InputReplyToMessage ) SetReplyToPeerID (value InputPeerClass ) {
i .Flags .Set (1 )
i .ReplyToPeerID = value
}
func (i *InputReplyToMessage ) GetReplyToPeerID () (value InputPeerClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .ReplyToPeerID , true
}
func (i *InputReplyToMessage ) SetQuoteText (value string ) {
i .Flags .Set (2 )
i .QuoteText = value
}
func (i *InputReplyToMessage ) GetQuoteText () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (2 ) {
return value , false
}
return i .QuoteText , true
}
func (i *InputReplyToMessage ) SetQuoteEntities (value []MessageEntityClass ) {
i .Flags .Set (3 )
i .QuoteEntities = value
}
func (i *InputReplyToMessage ) GetQuoteEntities () (value []MessageEntityClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (3 ) {
return value , false
}
return i .QuoteEntities , true
}
func (i *InputReplyToMessage ) SetQuoteOffset (value int ) {
i .Flags .Set (4 )
i .QuoteOffset = value
}
func (i *InputReplyToMessage ) GetQuoteOffset () (value int , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (4 ) {
return value , false
}
return i .QuoteOffset , true
}
func (i *InputReplyToMessage ) MapQuoteEntities () (value MessageEntityClassArray , ok bool ) {
if !i .Flags .Has (3 ) {
return value , false
}
return MessageEntityClassArray (i .QuoteEntities ), true
}
type InputReplyToStory struct {
UserID InputUserClass
StoryID int
}
const InputReplyToStoryTypeID = 0x15b0f283
func (i InputReplyToStory ) construct () InputReplyToClass { return &i }
var (
_ bin .Encoder = &InputReplyToStory {}
_ bin .Decoder = &InputReplyToStory {}
_ bin .BareEncoder = &InputReplyToStory {}
_ bin .BareDecoder = &InputReplyToStory {}
_ InputReplyToClass = &InputReplyToStory {}
)
func (i *InputReplyToStory ) Zero () bool {
if i == nil {
return true
}
if !(i .UserID == nil ) {
return false
}
if !(i .StoryID == 0 ) {
return false
}
return true
}
func (i *InputReplyToStory ) String () string {
if i == nil {
return "InputReplyToStory(nil)"
}
type Alias InputReplyToStory
return fmt .Sprintf ("InputReplyToStory%+v" , Alias (*i ))
}
func (i *InputReplyToStory ) FillFrom (from interface {
GetUserID () (value InputUserClass )
GetStoryID () (value int )
}) {
i .UserID = from .GetUserID ()
i .StoryID = from .GetStoryID ()
}
func (*InputReplyToStory ) TypeID () uint32 {
return InputReplyToStoryTypeID
}
func (*InputReplyToStory ) TypeName () string {
return "inputReplyToStory"
}
func (i *InputReplyToStory ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputReplyToStory" ,
ID : InputReplyToStoryTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "StoryID" ,
SchemaName : "story_id" ,
},
}
return typ
}
func (i *InputReplyToStory ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputReplyToStory#15b0f283 as nil" )
}
b .PutID (InputReplyToStoryTypeID )
return i .EncodeBare (b )
}
func (i *InputReplyToStory ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputReplyToStory#15b0f283 as nil" )
}
if i .UserID == nil {
return fmt .Errorf ("unable to encode inputReplyToStory#15b0f283: field user_id is nil" )
}
if err := i .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputReplyToStory#15b0f283: field user_id: %w" , err )
}
b .PutInt (i .StoryID )
return nil
}
func (i *InputReplyToStory ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputReplyToStory#15b0f283 to nil" )
}
if err := b .ConsumeID (InputReplyToStoryTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputReplyToStory#15b0f283: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputReplyToStory ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputReplyToStory#15b0f283 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToStory#15b0f283: field user_id: %w" , err )
}
i .UserID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputReplyToStory#15b0f283: field story_id: %w" , err )
}
i .StoryID = value
}
return nil
}
func (i *InputReplyToStory ) GetUserID () (value InputUserClass ) {
if i == nil {
return
}
return i .UserID
}
func (i *InputReplyToStory ) GetStoryID () (value int ) {
if i == nil {
return
}
return i .StoryID
}
const InputReplyToClassName = "InputReplyTo"
type InputReplyToClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputReplyToClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputReplyTo (buf *bin .Buffer ) (InputReplyToClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputReplyToMessageTypeID :
v := InputReplyToMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputReplyToClass: %w" , err )
}
return &v , nil
case InputReplyToStoryTypeID :
v := InputReplyToStory {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputReplyToClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputReplyToClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputReplyToBox struct {
InputReplyTo InputReplyToClass
}
func (b *InputReplyToBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputReplyToBox to nil" )
}
v , err := DecodeInputReplyTo (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputReplyTo = v
return nil
}
func (b *InputReplyToBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputReplyTo == nil {
return fmt .Errorf ("unable to encode InputReplyToClass as nil" )
}
return b .InputReplyTo .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 .