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 MessageFwdHeader struct {
Flags bin .Fields
Imported bool
FromID PeerClass
FromName string
Date int
ChannelPost int
PostAuthor string
SavedFromPeer PeerClass
SavedFromMsgID int
PsaType string
}
const MessageFwdHeaderTypeID = 0x5f777dce
var (
_ bin .Encoder = &MessageFwdHeader {}
_ bin .Decoder = &MessageFwdHeader {}
_ bin .BareEncoder = &MessageFwdHeader {}
_ bin .BareDecoder = &MessageFwdHeader {}
)
func (m *MessageFwdHeader ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Imported == false ) {
return false
}
if !(m .FromID == nil ) {
return false
}
if !(m .FromName == "" ) {
return false
}
if !(m .Date == 0 ) {
return false
}
if !(m .ChannelPost == 0 ) {
return false
}
if !(m .PostAuthor == "" ) {
return false
}
if !(m .SavedFromPeer == nil ) {
return false
}
if !(m .SavedFromMsgID == 0 ) {
return false
}
if !(m .PsaType == "" ) {
return false
}
return true
}
func (m *MessageFwdHeader ) String () string {
if m == nil {
return "MessageFwdHeader(nil)"
}
type Alias MessageFwdHeader
return fmt .Sprintf ("MessageFwdHeader%+v" , Alias (*m ))
}
func (m *MessageFwdHeader ) FillFrom (from interface {
GetImported () (value bool )
GetFromID () (value PeerClass , ok bool )
GetFromName () (value string , ok bool )
GetDate () (value int )
GetChannelPost () (value int , ok bool )
GetPostAuthor () (value string , ok bool )
GetSavedFromPeer () (value PeerClass , ok bool )
GetSavedFromMsgID () (value int , ok bool )
GetPsaType () (value string , ok bool )
}) {
m .Imported = from .GetImported ()
if val , ok := from .GetFromID (); ok {
m .FromID = val
}
if val , ok := from .GetFromName (); ok {
m .FromName = val
}
m .Date = from .GetDate ()
if val , ok := from .GetChannelPost (); ok {
m .ChannelPost = val
}
if val , ok := from .GetPostAuthor (); ok {
m .PostAuthor = val
}
if val , ok := from .GetSavedFromPeer (); ok {
m .SavedFromPeer = val
}
if val , ok := from .GetSavedFromMsgID (); ok {
m .SavedFromMsgID = val
}
if val , ok := from .GetPsaType (); ok {
m .PsaType = val
}
}
func (*MessageFwdHeader ) TypeID () uint32 {
return MessageFwdHeaderTypeID
}
func (*MessageFwdHeader ) TypeName () string {
return "messageFwdHeader"
}
func (m *MessageFwdHeader ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messageFwdHeader" ,
ID : MessageFwdHeaderTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Imported" ,
SchemaName : "imported" ,
Null : !m .Flags .Has (7 ),
},
{
Name : "FromID" ,
SchemaName : "from_id" ,
Null : !m .Flags .Has (0 ),
},
{
Name : "FromName" ,
SchemaName : "from_name" ,
Null : !m .Flags .Has (5 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "ChannelPost" ,
SchemaName : "channel_post" ,
Null : !m .Flags .Has (2 ),
},
{
Name : "PostAuthor" ,
SchemaName : "post_author" ,
Null : !m .Flags .Has (3 ),
},
{
Name : "SavedFromPeer" ,
SchemaName : "saved_from_peer" ,
Null : !m .Flags .Has (4 ),
},
{
Name : "SavedFromMsgID" ,
SchemaName : "saved_from_msg_id" ,
Null : !m .Flags .Has (4 ),
},
{
Name : "PsaType" ,
SchemaName : "psa_type" ,
Null : !m .Flags .Has (6 ),
},
}
return typ
}
func (m *MessageFwdHeader ) SetFlags () {
if !(m .Imported == false ) {
m .Flags .Set (7 )
}
if !(m .FromID == nil ) {
m .Flags .Set (0 )
}
if !(m .FromName == "" ) {
m .Flags .Set (5 )
}
if !(m .ChannelPost == 0 ) {
m .Flags .Set (2 )
}
if !(m .PostAuthor == "" ) {
m .Flags .Set (3 )
}
if !(m .SavedFromPeer == nil ) {
m .Flags .Set (4 )
}
if !(m .SavedFromMsgID == 0 ) {
m .Flags .Set (4 )
}
if !(m .PsaType == "" ) {
m .Flags .Set (6 )
}
}
func (m *MessageFwdHeader ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageFwdHeader#5f777dce as nil" )
}
b .PutID (MessageFwdHeaderTypeID )
return m .EncodeBare (b )
}
func (m *MessageFwdHeader ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messageFwdHeader#5f777dce as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageFwdHeader#5f777dce: field flags: %w" , err )
}
if m .Flags .Has (0 ) {
if m .FromID == nil {
return fmt .Errorf ("unable to encode messageFwdHeader#5f777dce: field from_id is nil" )
}
if err := m .FromID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageFwdHeader#5f777dce: field from_id: %w" , err )
}
}
if m .Flags .Has (5 ) {
b .PutString (m .FromName )
}
b .PutInt (m .Date )
if m .Flags .Has (2 ) {
b .PutInt (m .ChannelPost )
}
if m .Flags .Has (3 ) {
b .PutString (m .PostAuthor )
}
if m .Flags .Has (4 ) {
if m .SavedFromPeer == nil {
return fmt .Errorf ("unable to encode messageFwdHeader#5f777dce: field saved_from_peer is nil" )
}
if err := m .SavedFromPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messageFwdHeader#5f777dce: field saved_from_peer: %w" , err )
}
}
if m .Flags .Has (4 ) {
b .PutInt (m .SavedFromMsgID )
}
if m .Flags .Has (6 ) {
b .PutString (m .PsaType )
}
return nil
}
func (m *MessageFwdHeader ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageFwdHeader#5f777dce to nil" )
}
if err := b .ConsumeID (MessageFwdHeaderTypeID ); err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessageFwdHeader ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messageFwdHeader#5f777dce to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field flags: %w" , err )
}
}
m .Imported = m .Flags .Has (7 )
if m .Flags .Has (0 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field from_id: %w" , err )
}
m .FromID = value
}
if m .Flags .Has (5 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field from_name: %w" , err )
}
m .FromName = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field date: %w" , err )
}
m .Date = value
}
if m .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field channel_post: %w" , err )
}
m .ChannelPost = value
}
if m .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field post_author: %w" , err )
}
m .PostAuthor = value
}
if m .Flags .Has (4 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field saved_from_peer: %w" , err )
}
m .SavedFromPeer = value
}
if m .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field saved_from_msg_id: %w" , err )
}
m .SavedFromMsgID = value
}
if m .Flags .Has (6 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messageFwdHeader#5f777dce: field psa_type: %w" , err )
}
m .PsaType = value
}
return nil
}
func (m *MessageFwdHeader ) SetImported (value bool ) {
if value {
m .Flags .Set (7 )
m .Imported = true
} else {
m .Flags .Unset (7 )
m .Imported = false
}
}
func (m *MessageFwdHeader ) GetImported () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (7 )
}
func (m *MessageFwdHeader ) SetFromID (value PeerClass ) {
m .Flags .Set (0 )
m .FromID = value
}
func (m *MessageFwdHeader ) GetFromID () (value PeerClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (0 ) {
return value , false
}
return m .FromID , true
}
func (m *MessageFwdHeader ) SetFromName (value string ) {
m .Flags .Set (5 )
m .FromName = value
}
func (m *MessageFwdHeader ) GetFromName () (value string , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (5 ) {
return value , false
}
return m .FromName , true
}
func (m *MessageFwdHeader ) GetDate () (value int ) {
if m == nil {
return
}
return m .Date
}
func (m *MessageFwdHeader ) SetChannelPost (value int ) {
m .Flags .Set (2 )
m .ChannelPost = value
}
func (m *MessageFwdHeader ) GetChannelPost () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (2 ) {
return value , false
}
return m .ChannelPost , true
}
func (m *MessageFwdHeader ) SetPostAuthor (value string ) {
m .Flags .Set (3 )
m .PostAuthor = value
}
func (m *MessageFwdHeader ) GetPostAuthor () (value string , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (3 ) {
return value , false
}
return m .PostAuthor , true
}
func (m *MessageFwdHeader ) SetSavedFromPeer (value PeerClass ) {
m .Flags .Set (4 )
m .SavedFromPeer = value
}
func (m *MessageFwdHeader ) GetSavedFromPeer () (value PeerClass , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (4 ) {
return value , false
}
return m .SavedFromPeer , true
}
func (m *MessageFwdHeader ) SetSavedFromMsgID (value int ) {
m .Flags .Set (4 )
m .SavedFromMsgID = value
}
func (m *MessageFwdHeader ) GetSavedFromMsgID () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (4 ) {
return value , false
}
return m .SavedFromMsgID , true
}
func (m *MessageFwdHeader ) SetPsaType (value string ) {
m .Flags .Set (6 )
m .PsaType = value
}
func (m *MessageFwdHeader ) GetPsaType () (value string , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (6 ) {
return value , false
}
return m .PsaType , true
}
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 .