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 MessageEmpty struct {
Flags bin .Fields
ID int
PeerID PeerClass
}
const MessageEmptyTypeID = 0x90a6ca84
func (m MessageEmpty ) construct () MessageClass { return &m }
var (
_ bin .Encoder = &MessageEmpty {}
_ bin .Decoder = &MessageEmpty {}
_ bin .BareEncoder = &MessageEmpty {}
_ bin .BareDecoder = &MessageEmpty {}
_ MessageClass = &MessageEmpty {}
)
func (m *MessageEmpty ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .ID == 0 ) {
return false
}
if !(m .PeerID == nil ) {
return false
}
return true
}
func (m *MessageEmpty ) String () string {
if m == nil {
return "MessageEmpty(nil)"
}
type Alias MessageEmpty
return fmt .Sprintf ("MessageEmpty%+v" , Alias (*m ))
}
func (m *MessageEmpty ) FillFrom (from interface {
GetID () (value int )
GetPeerID () (value PeerClass , ok bool )
}) {
m .ID = from .GetID ()
if val , ok := from .GetPeerID (); ok {
m .PeerID = val
}
}
func (*MessageEmpty ) TypeID () uint32 {
return MessageEmptyTypeID
}
func (*MessageEmpty ) TypeName () string {
return "messageEmpty"
}
func (m *MessageEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messageEmpty" ,
ID : MessageEmptyTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "PeerID" ,
SchemaName : "peer_id" ,
Null : !m .Flags .Has (0 ),
},
}
return typ
}
func (m *MessageEmpty ) SetFlags () {
if !(m .PeerID == nil ) {
m .Flags .Set (0 )
}
}
func (m *MessageEmpty ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageEmpty#90a6ca84 as nil" )
}
b .PutID (MessageEmptyTypeID )
return m .EncodeBare (b )
}
func (m *MessageEmpty ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageEmpty#90a6ca84 as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageEmpty#90a6ca84: field flags: %w" , err )
}
b .PutInt (m .ID )
if m .Flags .Has (0 ) {
if m .PeerID == nil {
return fmt .Errorf ("unable to encode messageEmpty#90a6ca84: field peer_id is nil" )
}
if err := m .PeerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageEmpty#90a6ca84: field peer_id: %w" , err )
}
}
return nil
}
func (m *MessageEmpty ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageEmpty#90a6ca84 to nil" )
}
if err := b .ConsumeID (MessageEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode messageEmpty#90a6ca84: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessageEmpty ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageEmpty#90a6ca84 to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messageEmpty#90a6ca84: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageEmpty#90a6ca84: field id: %w" , err )
}
m .ID = value
}
if m .Flags .Has (0 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messageEmpty#90a6ca84: field peer_id: %w" , err )
}
m .PeerID = value
}
return nil
}
func (m *MessageEmpty ) GetID () (value int ) {
if m == nil {
return
}
return m .ID
}
func (m *MessageEmpty ) SetPeerID (value PeerClass ) {
m .Flags .Set (0 )
m .PeerID = value
}
func (m *MessageEmpty ) GetPeerID () (value PeerClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (0 ) {
return value , false
}
return m .PeerID , true
}
type Message struct {
Flags bin .Fields
Out bool
Mentioned bool
MediaUnread bool
Silent bool
Post bool
FromScheduled bool
Legacy bool
EditHide bool
Pinned bool
Noforwards bool
InvertMedia bool
ID int
FromID PeerClass
PeerID PeerClass
FwdFrom MessageFwdHeader
ViaBotID int64
ReplyTo MessageReplyHeaderClass
Date int
Message string
Media MessageMediaClass
ReplyMarkup ReplyMarkupClass
Entities []MessageEntityClass
Views int
Forwards int
Replies MessageReplies
EditDate int
PostAuthor string
GroupedID int64
Reactions MessageReactions
RestrictionReason []RestrictionReason
TTLPeriod int
}
const MessageTypeID = 0x38116ee0
func (m Message ) construct () MessageClass { return &m }
var (
_ bin .Encoder = &Message {}
_ bin .Decoder = &Message {}
_ bin .BareEncoder = &Message {}
_ bin .BareDecoder = &Message {}
_ MessageClass = &Message {}
)
func (m *Message ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Out == false ) {
return false
}
if !(m .Mentioned == false ) {
return false
}
if !(m .MediaUnread == false ) {
return false
}
if !(m .Silent == false ) {
return false
}
if !(m .Post == false ) {
return false
}
if !(m .FromScheduled == false ) {
return false
}
if !(m .Legacy == false ) {
return false
}
if !(m .EditHide == false ) {
return false
}
if !(m .Pinned == false ) {
return false
}
if !(m .Noforwards == false ) {
return false
}
if !(m .InvertMedia == false ) {
return false
}
if !(m .ID == 0 ) {
return false
}
if !(m .FromID == nil ) {
return false
}
if !(m .PeerID == nil ) {
return false
}
if !(m .FwdFrom .Zero ()) {
return false
}
if !(m .ViaBotID == 0 ) {
return false
}
if !(m .ReplyTo == nil ) {
return false
}
if !(m .Date == 0 ) {
return false
}
if !(m .Message == "" ) {
return false
}
if !(m .Media == nil ) {
return false
}
if !(m .ReplyMarkup == nil ) {
return false
}
if !(m .Entities == nil ) {
return false
}
if !(m .Views == 0 ) {
return false
}
if !(m .Forwards == 0 ) {
return false
}
if !(m .Replies .Zero ()) {
return false
}
if !(m .EditDate == 0 ) {
return false
}
if !(m .PostAuthor == "" ) {
return false
}
if !(m .GroupedID == 0 ) {
return false
}
if !(m .Reactions .Zero ()) {
return false
}
if !(m .RestrictionReason == nil ) {
return false
}
if !(m .TTLPeriod == 0 ) {
return false
}
return true
}
func (m *Message ) String () string {
if m == nil {
return "Message(nil)"
}
type Alias Message
return fmt .Sprintf ("Message%+v" , Alias (*m ))
}
func (m *Message ) FillFrom (from interface {
GetOut () (value bool )
GetMentioned () (value bool )
GetMediaUnread () (value bool )
GetSilent () (value bool )
GetPost () (value bool )
GetFromScheduled () (value bool )
GetLegacy () (value bool )
GetEditHide () (value bool )
GetPinned () (value bool )
GetNoforwards () (value bool )
GetInvertMedia () (value bool )
GetID () (value int )
GetFromID () (value PeerClass , ok bool )
GetPeerID () (value PeerClass )
GetFwdFrom () (value MessageFwdHeader , ok bool )
GetViaBotID () (value int64 , ok bool )
GetReplyTo () (value MessageReplyHeaderClass , ok bool )
GetDate () (value int )
GetMessage () (value string )
GetMedia () (value MessageMediaClass , ok bool )
GetReplyMarkup () (value ReplyMarkupClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetViews () (value int , ok bool )
GetForwards () (value int , ok bool )
GetReplies () (value MessageReplies , ok bool )
GetEditDate () (value int , ok bool )
GetPostAuthor () (value string , ok bool )
GetGroupedID () (value int64 , ok bool )
GetReactions () (value MessageReactions , ok bool )
GetRestrictionReason () (value []RestrictionReason , ok bool )
GetTTLPeriod () (value int , ok bool )
}) {
m .Out = from .GetOut ()
m .Mentioned = from .GetMentioned ()
m .MediaUnread = from .GetMediaUnread ()
m .Silent = from .GetSilent ()
m .Post = from .GetPost ()
m .FromScheduled = from .GetFromScheduled ()
m .Legacy = from .GetLegacy ()
m .EditHide = from .GetEditHide ()
m .Pinned = from .GetPinned ()
m .Noforwards = from .GetNoforwards ()
m .InvertMedia = from .GetInvertMedia ()
m .ID = from .GetID ()
if val , ok := from .GetFromID (); ok {
m .FromID = val
}
m .PeerID = from .GetPeerID ()
if val , ok := from .GetFwdFrom (); ok {
m .FwdFrom = val
}
if val , ok := from .GetViaBotID (); ok {
m .ViaBotID = val
}
if val , ok := from .GetReplyTo (); ok {
m .ReplyTo = val
}
m .Date = from .GetDate ()
m .Message = from .GetMessage ()
if val , ok := from .GetMedia (); ok {
m .Media = val
}
if val , ok := from .GetReplyMarkup (); ok {
m .ReplyMarkup = val
}
if val , ok := from .GetEntities (); ok {
m .Entities = val
}
if val , ok := from .GetViews (); ok {
m .Views = val
}
if val , ok := from .GetForwards (); ok {
m .Forwards = val
}
if val , ok := from .GetReplies (); ok {
m .Replies = val
}
if val , ok := from .GetEditDate (); ok {
m .EditDate = val
}
if val , ok := from .GetPostAuthor (); ok {
m .PostAuthor = val
}
if val , ok := from .GetGroupedID (); ok {
m .GroupedID = val
}
if val , ok := from .GetReactions (); ok {
m .Reactions = val
}
if val , ok := from .GetRestrictionReason (); ok {
m .RestrictionReason = val
}
if val , ok := from .GetTTLPeriod (); ok {
m .TTLPeriod = val
}
}
func (*Message ) TypeID () uint32 {
return MessageTypeID
}
func (*Message ) TypeName () string {
return "message"
}
func (m *Message ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "message" ,
ID : MessageTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Out" ,
SchemaName : "out" ,
Null : !m .Flags .Has (1 ),
},
{
Name : "Mentioned" ,
SchemaName : "mentioned" ,
Null : !m .Flags .Has (4 ),
},
{
Name : "MediaUnread" ,
SchemaName : "media_unread" ,
Null : !m .Flags .Has (5 ),
},
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !m .Flags .Has (13 ),
},
{
Name : "Post" ,
SchemaName : "post" ,
Null : !m .Flags .Has (14 ),
},
{
Name : "FromScheduled" ,
SchemaName : "from_scheduled" ,
Null : !m .Flags .Has (18 ),
},
{
Name : "Legacy" ,
SchemaName : "legacy" ,
Null : !m .Flags .Has (19 ),
},
{
Name : "EditHide" ,
SchemaName : "edit_hide" ,
Null : !m .Flags .Has (21 ),
},
{
Name : "Pinned" ,
SchemaName : "pinned" ,
Null : !m .Flags .Has (24 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !m .Flags .Has (26 ),
},
{
Name : "InvertMedia" ,
SchemaName : "invert_media" ,
Null : !m .Flags .Has (27 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "FromID" ,
SchemaName : "from_id" ,
Null : !m .Flags .Has (8 ),
},
{
Name : "PeerID" ,
SchemaName : "peer_id" ,
},
{
Name : "FwdFrom" ,
SchemaName : "fwd_from" ,
Null : !m .Flags .Has (2 ),
},
{
Name : "ViaBotID" ,
SchemaName : "via_bot_id" ,
Null : !m .Flags .Has (11 ),
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !m .Flags .Has (3 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Media" ,
SchemaName : "media" ,
Null : !m .Flags .Has (9 ),
},
{
Name : "ReplyMarkup" ,
SchemaName : "reply_markup" ,
Null : !m .Flags .Has (6 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !m .Flags .Has (7 ),
},
{
Name : "Views" ,
SchemaName : "views" ,
Null : !m .Flags .Has (10 ),
},
{
Name : "Forwards" ,
SchemaName : "forwards" ,
Null : !m .Flags .Has (10 ),
},
{
Name : "Replies" ,
SchemaName : "replies" ,
Null : !m .Flags .Has (23 ),
},
{
Name : "EditDate" ,
SchemaName : "edit_date" ,
Null : !m .Flags .Has (15 ),
},
{
Name : "PostAuthor" ,
SchemaName : "post_author" ,
Null : !m .Flags .Has (16 ),
},
{
Name : "GroupedID" ,
SchemaName : "grouped_id" ,
Null : !m .Flags .Has (17 ),
},
{
Name : "Reactions" ,
SchemaName : "reactions" ,
Null : !m .Flags .Has (20 ),
},
{
Name : "RestrictionReason" ,
SchemaName : "restriction_reason" ,
Null : !m .Flags .Has (22 ),
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !m .Flags .Has (25 ),
},
}
return typ
}
func (m *Message ) SetFlags () {
if !(m .Out == false ) {
m .Flags .Set (1 )
}
if !(m .Mentioned == false ) {
m .Flags .Set (4 )
}
if !(m .MediaUnread == false ) {
m .Flags .Set (5 )
}
if !(m .Silent == false ) {
m .Flags .Set (13 )
}
if !(m .Post == false ) {
m .Flags .Set (14 )
}
if !(m .FromScheduled == false ) {
m .Flags .Set (18 )
}
if !(m .Legacy == false ) {
m .Flags .Set (19 )
}
if !(m .EditHide == false ) {
m .Flags .Set (21 )
}
if !(m .Pinned == false ) {
m .Flags .Set (24 )
}
if !(m .Noforwards == false ) {
m .Flags .Set (26 )
}
if !(m .InvertMedia == false ) {
m .Flags .Set (27 )
}
if !(m .FromID == nil ) {
m .Flags .Set (8 )
}
if !(m .FwdFrom .Zero ()) {
m .Flags .Set (2 )
}
if !(m .ViaBotID == 0 ) {
m .Flags .Set (11 )
}
if !(m .ReplyTo == nil ) {
m .Flags .Set (3 )
}
if !(m .Media == nil ) {
m .Flags .Set (9 )
}
if !(m .ReplyMarkup == nil ) {
m .Flags .Set (6 )
}
if !(m .Entities == nil ) {
m .Flags .Set (7 )
}
if !(m .Views == 0 ) {
m .Flags .Set (10 )
}
if !(m .Forwards == 0 ) {
m .Flags .Set (10 )
}
if !(m .Replies .Zero ()) {
m .Flags .Set (23 )
}
if !(m .EditDate == 0 ) {
m .Flags .Set (15 )
}
if !(m .PostAuthor == "" ) {
m .Flags .Set (16 )
}
if !(m .GroupedID == 0 ) {
m .Flags .Set (17 )
}
if !(m .Reactions .Zero ()) {
m .Flags .Set (20 )
}
if !(m .RestrictionReason == nil ) {
m .Flags .Set (22 )
}
if !(m .TTLPeriod == 0 ) {
m .Flags .Set (25 )
}
}
func (m *Message ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode message#38116ee0 as nil" )
}
b .PutID (MessageTypeID )
return m .EncodeBare (b )
}
func (m *Message ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode message#38116ee0 as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field flags: %w" , err )
}
b .PutInt (m .ID )
if m .Flags .Has (8 ) {
if m .FromID == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field from_id is nil" )
}
if err := m .FromID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field from_id: %w" , err )
}
}
if m .PeerID == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field peer_id is nil" )
}
if err := m .PeerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field peer_id: %w" , err )
}
if m .Flags .Has (2 ) {
if err := m .FwdFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field fwd_from: %w" , err )
}
}
if m .Flags .Has (11 ) {
b .PutLong (m .ViaBotID )
}
if m .Flags .Has (3 ) {
if m .ReplyTo == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field reply_to is nil" )
}
if err := m .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field reply_to: %w" , err )
}
}
b .PutInt (m .Date )
b .PutString (m .Message )
if m .Flags .Has (9 ) {
if m .Media == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field media is nil" )
}
if err := m .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field media: %w" , err )
}
}
if m .Flags .Has (6 ) {
if m .ReplyMarkup == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field reply_markup is nil" )
}
if err := m .ReplyMarkup .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field reply_markup: %w" , err )
}
}
if m .Flags .Has (7 ) {
b .PutVectorHeader (len (m .Entities ))
for idx , v := range m .Entities {
if v == nil {
return fmt .Errorf ("unable to encode message#38116ee0: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field entities element with index %d: %w" , idx , err )
}
}
}
if m .Flags .Has (10 ) {
b .PutInt (m .Views )
}
if m .Flags .Has (10 ) {
b .PutInt (m .Forwards )
}
if m .Flags .Has (23 ) {
if err := m .Replies .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field replies: %w" , err )
}
}
if m .Flags .Has (15 ) {
b .PutInt (m .EditDate )
}
if m .Flags .Has (16 ) {
b .PutString (m .PostAuthor )
}
if m .Flags .Has (17 ) {
b .PutLong (m .GroupedID )
}
if m .Flags .Has (20 ) {
if err := m .Reactions .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field reactions: %w" , err )
}
}
if m .Flags .Has (22 ) {
b .PutVectorHeader (len (m .RestrictionReason ))
for idx , v := range m .RestrictionReason {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode message#38116ee0: field restriction_reason element with index %d: %w" , idx , err )
}
}
}
if m .Flags .Has (25 ) {
b .PutInt (m .TTLPeriod )
}
return nil
}
func (m *Message ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode message#38116ee0 to nil" )
}
if err := b .ConsumeID (MessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: %w" , err )
}
return m .DecodeBare (b )
}
func (m *Message ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode message#38116ee0 to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field flags: %w" , err )
}
}
m .Out = m .Flags .Has (1 )
m .Mentioned = m .Flags .Has (4 )
m .MediaUnread = m .Flags .Has (5 )
m .Silent = m .Flags .Has (13 )
m .Post = m .Flags .Has (14 )
m .FromScheduled = m .Flags .Has (18 )
m .Legacy = m .Flags .Has (19 )
m .EditHide = m .Flags .Has (21 )
m .Pinned = m .Flags .Has (24 )
m .Noforwards = m .Flags .Has (26 )
m .InvertMedia = m .Flags .Has (27 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field id: %w" , err )
}
m .ID = value
}
if m .Flags .Has (8 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field from_id: %w" , err )
}
m .FromID = value
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field peer_id: %w" , err )
}
m .PeerID = value
}
if m .Flags .Has (2 ) {
if err := m .FwdFrom .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field fwd_from: %w" , err )
}
}
if m .Flags .Has (11 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field via_bot_id: %w" , err )
}
m .ViaBotID = value
}
if m .Flags .Has (3 ) {
value , err := DecodeMessageReplyHeader (b )
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field reply_to: %w" , err )
}
m .ReplyTo = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field date: %w" , err )
}
m .Date = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field message: %w" , err )
}
m .Message = value
}
if m .Flags .Has (9 ) {
value , err := DecodeMessageMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field media: %w" , err )
}
m .Media = value
}
if m .Flags .Has (6 ) {
value , err := DecodeReplyMarkup (b )
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field reply_markup: %w" , err )
}
m .ReplyMarkup = value
}
if m .Flags .Has (7 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field entities: %w" , err )
}
if headerLen > 0 {
m .Entities = 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 message#38116ee0: field entities: %w" , err )
}
m .Entities = append (m .Entities , value )
}
}
if m .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field views: %w" , err )
}
m .Views = value
}
if m .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field forwards: %w" , err )
}
m .Forwards = value
}
if m .Flags .Has (23 ) {
if err := m .Replies .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field replies: %w" , err )
}
}
if m .Flags .Has (15 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field edit_date: %w" , err )
}
m .EditDate = value
}
if m .Flags .Has (16 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field post_author: %w" , err )
}
m .PostAuthor = value
}
if m .Flags .Has (17 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field grouped_id: %w" , err )
}
m .GroupedID = value
}
if m .Flags .Has (20 ) {
if err := m .Reactions .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field reactions: %w" , err )
}
}
if m .Flags .Has (22 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field restriction_reason: %w" , err )
}
if headerLen > 0 {
m .RestrictionReason = make ([]RestrictionReason , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value RestrictionReason
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field restriction_reason: %w" , err )
}
m .RestrictionReason = append (m .RestrictionReason , value )
}
}
if m .Flags .Has (25 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode message#38116ee0: field ttl_period: %w" , err )
}
m .TTLPeriod = value
}
return nil
}
func (m *Message ) SetOut (value bool ) {
if value {
m .Flags .Set (1 )
m .Out = true
} else {
m .Flags .Unset (1 )
m .Out = false
}
}
func (m *Message ) GetOut () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (1 )
}
func (m *Message ) SetMentioned (value bool ) {
if value {
m .Flags .Set (4 )
m .Mentioned = true
} else {
m .Flags .Unset (4 )
m .Mentioned = false
}
}
func (m *Message ) GetMentioned () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (4 )
}
func (m *Message ) SetMediaUnread (value bool ) {
if value {
m .Flags .Set (5 )
m .MediaUnread = true
} else {
m .Flags .Unset (5 )
m .MediaUnread = false
}
}
func (m *Message ) GetMediaUnread () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (5 )
}
func (m *Message ) SetSilent (value bool ) {
if value {
m .Flags .Set (13 )
m .Silent = true
} else {
m .Flags .Unset (13 )
m .Silent = false
}
}
func (m *Message ) GetSilent () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (13 )
}
func (m *Message ) SetPost (value bool ) {
if value {
m .Flags .Set (14 )
m .Post = true
} else {
m .Flags .Unset (14 )
m .Post = false
}
}
func (m *Message ) GetPost () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (14 )
}
func (m *Message ) SetFromScheduled (value bool ) {
if value {
m .Flags .Set (18 )
m .FromScheduled = true
} else {
m .Flags .Unset (18 )
m .FromScheduled = false
}
}
func (m *Message ) GetFromScheduled () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (18 )
}
func (m *Message ) SetLegacy (value bool ) {
if value {
m .Flags .Set (19 )
m .Legacy = true
} else {
m .Flags .Unset (19 )
m .Legacy = false
}
}
func (m *Message ) GetLegacy () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (19 )
}
func (m *Message ) SetEditHide (value bool ) {
if value {
m .Flags .Set (21 )
m .EditHide = true
} else {
m .Flags .Unset (21 )
m .EditHide = false
}
}
func (m *Message ) GetEditHide () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (21 )
}
func (m *Message ) SetPinned (value bool ) {
if value {
m .Flags .Set (24 )
m .Pinned = true
} else {
m .Flags .Unset (24 )
m .Pinned = false
}
}
func (m *Message ) GetPinned () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (24 )
}
func (m *Message ) SetNoforwards (value bool ) {
if value {
m .Flags .Set (26 )
m .Noforwards = true
} else {
m .Flags .Unset (26 )
m .Noforwards = false
}
}
func (m *Message ) GetNoforwards () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (26 )
}
func (m *Message ) SetInvertMedia (value bool ) {
if value {
m .Flags .Set (27 )
m .InvertMedia = true
} else {
m .Flags .Unset (27 )
m .InvertMedia = false
}
}
func (m *Message ) GetInvertMedia () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (27 )
}
func (m *Message ) GetID () (value int ) {
if m == nil {
return
}
return m .ID
}
func (m *Message ) SetFromID (value PeerClass ) {
m .Flags .Set (8 )
m .FromID = value
}
func (m *Message ) GetFromID () (value PeerClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (8 ) {
return value , false
}
return m .FromID , true
}
func (m *Message ) GetPeerID () (value PeerClass ) {
if m == nil {
return
}
return m .PeerID
}
func (m *Message ) SetFwdFrom (value MessageFwdHeader ) {
m .Flags .Set (2 )
m .FwdFrom = value
}
func (m *Message ) GetFwdFrom () (value MessageFwdHeader , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (2 ) {
return value , false
}
return m .FwdFrom , true
}
func (m *Message ) SetViaBotID (value int64 ) {
m .Flags .Set (11 )
m .ViaBotID = value
}
func (m *Message ) GetViaBotID () (value int64 , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (11 ) {
return value , false
}
return m .ViaBotID , true
}
func (m *Message ) SetReplyTo (value MessageReplyHeaderClass ) {
m .Flags .Set (3 )
m .ReplyTo = value
}
func (m *Message ) GetReplyTo () (value MessageReplyHeaderClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (3 ) {
return value , false
}
return m .ReplyTo , true
}
func (m *Message ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
func (m *Message ) GetMessage () (value string ) {
if m == nil {
return
}
return m .Message
}
func (m *Message ) SetMedia (value MessageMediaClass ) {
m .Flags .Set (9 )
m .Media = value
}
func (m *Message ) GetMedia () (value MessageMediaClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (9 ) {
return value , false
}
return m .Media , true
}
func (m *Message ) SetReplyMarkup (value ReplyMarkupClass ) {
m .Flags .Set (6 )
m .ReplyMarkup = value
}
func (m *Message ) GetReplyMarkup () (value ReplyMarkupClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (6 ) {
return value , false
}
return m .ReplyMarkup , true
}
func (m *Message ) SetEntities (value []MessageEntityClass ) {
m .Flags .Set (7 )
m .Entities = value
}
func (m *Message ) GetEntities () (value []MessageEntityClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (7 ) {
return value , false
}
return m .Entities , true
}
func (m *Message ) SetViews (value int ) {
m .Flags .Set (10 )
m .Views = value
}
func (m *Message ) GetViews () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (10 ) {
return value , false
}
return m .Views , true
}
func (m *Message ) SetForwards (value int ) {
m .Flags .Set (10 )
m .Forwards = value
}
func (m *Message ) GetForwards () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (10 ) {
return value , false
}
return m .Forwards , true
}
func (m *Message ) SetReplies (value MessageReplies ) {
m .Flags .Set (23 )
m .Replies = value
}
func (m *Message ) GetReplies () (value MessageReplies , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (23 ) {
return value , false
}
return m .Replies , true
}
func (m *Message ) SetEditDate (value int ) {
m .Flags .Set (15 )
m .EditDate = value
}
func (m *Message ) GetEditDate () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (15 ) {
return value , false
}
return m .EditDate , true
}
func (m *Message ) SetPostAuthor (value string ) {
m .Flags .Set (16 )
m .PostAuthor = value
}
func (m *Message ) GetPostAuthor () (value string , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (16 ) {
return value , false
}
return m .PostAuthor , true
}
func (m *Message ) SetGroupedID (value int64 ) {
m .Flags .Set (17 )
m .GroupedID = value
}
func (m *Message ) GetGroupedID () (value int64 , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (17 ) {
return value , false
}
return m .GroupedID , true
}
func (m *Message ) SetReactions (value MessageReactions ) {
m .Flags .Set (20 )
m .Reactions = value
}
func (m *Message ) GetReactions () (value MessageReactions , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (20 ) {
return value , false
}
return m .Reactions , true
}
func (m *Message ) SetRestrictionReason (value []RestrictionReason ) {
m .Flags .Set (22 )
m .RestrictionReason = value
}
func (m *Message ) GetRestrictionReason () (value []RestrictionReason , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (22 ) {
return value , false
}
return m .RestrictionReason , true
}
func (m *Message ) SetTTLPeriod (value int ) {
m .Flags .Set (25 )
m .TTLPeriod = value
}
func (m *Message ) GetTTLPeriod () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (25 ) {
return value , false
}
return m .TTLPeriod , true
}
func (m *Message ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !m .Flags .Has (7 ) {
return value , false
}
return MessageEntityClassArray (m .Entities ), true
}
type MessageService struct {
Flags bin .Fields
Out bool
Mentioned bool
MediaUnread bool
Silent bool
Post bool
Legacy bool
ID int
FromID PeerClass
PeerID PeerClass
ReplyTo MessageReplyHeaderClass
Date int
Action MessageActionClass
TTLPeriod int
}
const MessageServiceTypeID = 0x2b085862
func (m MessageService ) construct () MessageClass { return &m }
var (
_ bin .Encoder = &MessageService {}
_ bin .Decoder = &MessageService {}
_ bin .BareEncoder = &MessageService {}
_ bin .BareDecoder = &MessageService {}
_ MessageClass = &MessageService {}
)
func (m *MessageService ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Out == false ) {
return false
}
if !(m .Mentioned == false ) {
return false
}
if !(m .MediaUnread == false ) {
return false
}
if !(m .Silent == false ) {
return false
}
if !(m .Post == false ) {
return false
}
if !(m .Legacy == false ) {
return false
}
if !(m .ID == 0 ) {
return false
}
if !(m .FromID == nil ) {
return false
}
if !(m .PeerID == nil ) {
return false
}
if !(m .ReplyTo == nil ) {
return false
}
if !(m .Date == 0 ) {
return false
}
if !(m .Action == nil ) {
return false
}
if !(m .TTLPeriod == 0 ) {
return false
}
return true
}
func (m *MessageService ) String () string {
if m == nil {
return "MessageService(nil)"
}
type Alias MessageService
return fmt .Sprintf ("MessageService%+v" , Alias (*m ))
}
func (m *MessageService ) FillFrom (from interface {
GetOut () (value bool )
GetMentioned () (value bool )
GetMediaUnread () (value bool )
GetSilent () (value bool )
GetPost () (value bool )
GetLegacy () (value bool )
GetID () (value int )
GetFromID () (value PeerClass , ok bool )
GetPeerID () (value PeerClass )
GetReplyTo () (value MessageReplyHeaderClass , ok bool )
GetDate () (value int )
GetAction () (value MessageActionClass )
GetTTLPeriod () (value int , ok bool )
}) {
m .Out = from .GetOut ()
m .Mentioned = from .GetMentioned ()
m .MediaUnread = from .GetMediaUnread ()
m .Silent = from .GetSilent ()
m .Post = from .GetPost ()
m .Legacy = from .GetLegacy ()
m .ID = from .GetID ()
if val , ok := from .GetFromID (); ok {
m .FromID = val
}
m .PeerID = from .GetPeerID ()
if val , ok := from .GetReplyTo (); ok {
m .ReplyTo = val
}
m .Date = from .GetDate ()
m .Action = from .GetAction ()
if val , ok := from .GetTTLPeriod (); ok {
m .TTLPeriod = val
}
}
func (*MessageService ) TypeID () uint32 {
return MessageServiceTypeID
}
func (*MessageService ) TypeName () string {
return "messageService"
}
func (m *MessageService ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messageService" ,
ID : MessageServiceTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Out" ,
SchemaName : "out" ,
Null : !m .Flags .Has (1 ),
},
{
Name : "Mentioned" ,
SchemaName : "mentioned" ,
Null : !m .Flags .Has (4 ),
},
{
Name : "MediaUnread" ,
SchemaName : "media_unread" ,
Null : !m .Flags .Has (5 ),
},
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !m .Flags .Has (13 ),
},
{
Name : "Post" ,
SchemaName : "post" ,
Null : !m .Flags .Has (14 ),
},
{
Name : "Legacy" ,
SchemaName : "legacy" ,
Null : !m .Flags .Has (19 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "FromID" ,
SchemaName : "from_id" ,
Null : !m .Flags .Has (8 ),
},
{
Name : "PeerID" ,
SchemaName : "peer_id" ,
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !m .Flags .Has (3 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Action" ,
SchemaName : "action" ,
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !m .Flags .Has (25 ),
},
}
return typ
}
func (m *MessageService ) SetFlags () {
if !(m .Out == false ) {
m .Flags .Set (1 )
}
if !(m .Mentioned == false ) {
m .Flags .Set (4 )
}
if !(m .MediaUnread == false ) {
m .Flags .Set (5 )
}
if !(m .Silent == false ) {
m .Flags .Set (13 )
}
if !(m .Post == false ) {
m .Flags .Set (14 )
}
if !(m .Legacy == false ) {
m .Flags .Set (19 )
}
if !(m .FromID == nil ) {
m .Flags .Set (8 )
}
if !(m .ReplyTo == nil ) {
m .Flags .Set (3 )
}
if !(m .TTLPeriod == 0 ) {
m .Flags .Set (25 )
}
}
func (m *MessageService ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageService#2b085862 as nil" )
}
b .PutID (MessageServiceTypeID )
return m .EncodeBare (b )
}
func (m *MessageService ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageService#2b085862 as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field flags: %w" , err )
}
b .PutInt (m .ID )
if m .Flags .Has (8 ) {
if m .FromID == nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field from_id is nil" )
}
if err := m .FromID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field from_id: %w" , err )
}
}
if m .PeerID == nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field peer_id is nil" )
}
if err := m .PeerID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field peer_id: %w" , err )
}
if m .Flags .Has (3 ) {
if m .ReplyTo == nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field reply_to is nil" )
}
if err := m .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field reply_to: %w" , err )
}
}
b .PutInt (m .Date )
if m .Action == nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field action is nil" )
}
if err := m .Action .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageService#2b085862: field action: %w" , err )
}
if m .Flags .Has (25 ) {
b .PutInt (m .TTLPeriod )
}
return nil
}
func (m *MessageService ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageService#2b085862 to nil" )
}
if err := b .ConsumeID (MessageServiceTypeID ); err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessageService ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageService#2b085862 to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field flags: %w" , err )
}
}
m .Out = m .Flags .Has (1 )
m .Mentioned = m .Flags .Has (4 )
m .MediaUnread = m .Flags .Has (5 )
m .Silent = m .Flags .Has (13 )
m .Post = m .Flags .Has (14 )
m .Legacy = m .Flags .Has (19 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field id: %w" , err )
}
m .ID = value
}
if m .Flags .Has (8 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field from_id: %w" , err )
}
m .FromID = value
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field peer_id: %w" , err )
}
m .PeerID = value
}
if m .Flags .Has (3 ) {
value , err := DecodeMessageReplyHeader (b )
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field reply_to: %w" , err )
}
m .ReplyTo = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field date: %w" , err )
}
m .Date = value
}
{
value , err := DecodeMessageAction (b )
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field action: %w" , err )
}
m .Action = value
}
if m .Flags .Has (25 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageService#2b085862: field ttl_period: %w" , err )
}
m .TTLPeriod = value
}
return nil
}
func (m *MessageService ) SetOut (value bool ) {
if value {
m .Flags .Set (1 )
m .Out = true
} else {
m .Flags .Unset (1 )
m .Out = false
}
}
func (m *MessageService ) GetOut () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (1 )
}
func (m *MessageService ) SetMentioned (value bool ) {
if value {
m .Flags .Set (4 )
m .Mentioned = true
} else {
m .Flags .Unset (4 )
m .Mentioned = false
}
}
func (m *MessageService ) GetMentioned () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (4 )
}
func (m *MessageService ) SetMediaUnread (value bool ) {
if value {
m .Flags .Set (5 )
m .MediaUnread = true
} else {
m .Flags .Unset (5 )
m .MediaUnread = false
}
}
func (m *MessageService ) GetMediaUnread () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (5 )
}
func (m *MessageService ) SetSilent (value bool ) {
if value {
m .Flags .Set (13 )
m .Silent = true
} else {
m .Flags .Unset (13 )
m .Silent = false
}
}
func (m *MessageService ) GetSilent () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (13 )
}
func (m *MessageService ) SetPost (value bool ) {
if value {
m .Flags .Set (14 )
m .Post = true
} else {
m .Flags .Unset (14 )
m .Post = false
}
}
func (m *MessageService ) GetPost () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (14 )
}
func (m *MessageService ) SetLegacy (value bool ) {
if value {
m .Flags .Set (19 )
m .Legacy = true
} else {
m .Flags .Unset (19 )
m .Legacy = false
}
}
func (m *MessageService ) GetLegacy () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (19 )
}
func (m *MessageService ) GetID () (value int ) {
if m == nil {
return
}
return m .ID
}
func (m *MessageService ) SetFromID (value PeerClass ) {
m .Flags .Set (8 )
m .FromID = value
}
func (m *MessageService ) GetFromID () (value PeerClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (8 ) {
return value , false
}
return m .FromID , true
}
func (m *MessageService ) GetPeerID () (value PeerClass ) {
if m == nil {
return
}
return m .PeerID
}
func (m *MessageService ) SetReplyTo (value MessageReplyHeaderClass ) {
m .Flags .Set (3 )
m .ReplyTo = value
}
func (m *MessageService ) GetReplyTo () (value MessageReplyHeaderClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (3 ) {
return value , false
}
return m .ReplyTo , true
}
func (m *MessageService ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
func (m *MessageService ) GetAction () (value MessageActionClass ) {
if m == nil {
return
}
return m .Action
}
func (m *MessageService ) SetTTLPeriod (value int ) {
m .Flags .Set (25 )
m .TTLPeriod = value
}
func (m *MessageService ) GetTTLPeriod () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (25 ) {
return value , false
}
return m .TTLPeriod , true
}
const MessageClassName = "Message"
type MessageClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int )
AsNotEmpty () (NotEmptyMessage , bool )
}
func (m *Message ) AsInputMessageID () *InputMessageID {
value := new (InputMessageID )
value .ID = m .GetID ()
return value
}
func (m *Message ) AsInputMessageReplyTo () *InputMessageReplyTo {
value := new (InputMessageReplyTo )
value .ID = m .GetID ()
return value
}
type NotEmptyMessage interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetOut () (value bool )
GetMentioned () (value bool )
GetMediaUnread () (value bool )
GetSilent () (value bool )
GetPost () (value bool )
GetLegacy () (value bool )
GetID () (value int )
GetFromID () (value PeerClass , ok bool )
GetPeerID () (value PeerClass )
GetReplyTo () (value MessageReplyHeaderClass , ok bool )
GetDate () (value int )
GetTTLPeriod () (value int , ok bool )
}
func (m *MessageEmpty ) AsNotEmpty () (NotEmptyMessage , bool ) {
value , ok := (MessageClass (m )).(NotEmptyMessage )
return value , ok
}
func (m *Message ) AsNotEmpty () (NotEmptyMessage , bool ) {
value , ok := (MessageClass (m )).(NotEmptyMessage )
return value , ok
}
func (m *MessageService ) AsNotEmpty () (NotEmptyMessage , bool ) {
value , ok := (MessageClass (m )).(NotEmptyMessage )
return value , ok
}
func DecodeMessage (buf *bin .Buffer ) (MessageClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessageEmptyTypeID :
v := MessageEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessageClass: %w" , err )
}
return &v , nil
case MessageTypeID :
v := Message {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessageClass: %w" , err )
}
return &v , nil
case MessageServiceTypeID :
v := MessageService {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessageClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessageClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessageBox struct {
Message MessageClass
}
func (b *MessageBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessageBox to nil" )
}
v , err := DecodeMessage (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Message = v
return nil
}
func (b *MessageBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Message == nil {
return fmt .Errorf ("unable to encode MessageClass as nil" )
}
return b .Message .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 .