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 MessagesDiscussionMessage struct {
Flags bin .Fields
Messages []MessageClass
MaxID int
ReadInboxMaxID int
ReadOutboxMaxID int
UnreadCount int
Chats []ChatClass
Users []UserClass
}
const MessagesDiscussionMessageTypeID = 0xa6341782
var (
_ bin .Encoder = &MessagesDiscussionMessage {}
_ bin .Decoder = &MessagesDiscussionMessage {}
_ bin .BareEncoder = &MessagesDiscussionMessage {}
_ bin .BareDecoder = &MessagesDiscussionMessage {}
)
func (d *MessagesDiscussionMessage ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Messages == nil ) {
return false
}
if !(d .MaxID == 0 ) {
return false
}
if !(d .ReadInboxMaxID == 0 ) {
return false
}
if !(d .ReadOutboxMaxID == 0 ) {
return false
}
if !(d .UnreadCount == 0 ) {
return false
}
if !(d .Chats == nil ) {
return false
}
if !(d .Users == nil ) {
return false
}
return true
}
func (d *MessagesDiscussionMessage ) String () string {
if d == nil {
return "MessagesDiscussionMessage(nil)"
}
type Alias MessagesDiscussionMessage
return fmt .Sprintf ("MessagesDiscussionMessage%+v" , Alias (*d ))
}
func (d *MessagesDiscussionMessage ) FillFrom (from interface {
GetMessages () (value []MessageClass )
GetMaxID () (value int , ok bool )
GetReadInboxMaxID () (value int , ok bool )
GetReadOutboxMaxID () (value int , ok bool )
GetUnreadCount () (value int )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
d .Messages = from .GetMessages ()
if val , ok := from .GetMaxID (); ok {
d .MaxID = val
}
if val , ok := from .GetReadInboxMaxID (); ok {
d .ReadInboxMaxID = val
}
if val , ok := from .GetReadOutboxMaxID (); ok {
d .ReadOutboxMaxID = val
}
d .UnreadCount = from .GetUnreadCount ()
d .Chats = from .GetChats ()
d .Users = from .GetUsers ()
}
func (*MessagesDiscussionMessage ) TypeID () uint32 {
return MessagesDiscussionMessageTypeID
}
func (*MessagesDiscussionMessage ) TypeName () string {
return "messages.discussionMessage"
}
func (d *MessagesDiscussionMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.discussionMessage" ,
ID : MessagesDiscussionMessageTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "MaxID" ,
SchemaName : "max_id" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "ReadInboxMaxID" ,
SchemaName : "read_inbox_max_id" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "ReadOutboxMaxID" ,
SchemaName : "read_outbox_max_id" ,
Null : !d .Flags .Has (2 ),
},
{
Name : "UnreadCount" ,
SchemaName : "unread_count" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (d *MessagesDiscussionMessage ) SetFlags () {
if !(d .MaxID == 0 ) {
d .Flags .Set (0 )
}
if !(d .ReadInboxMaxID == 0 ) {
d .Flags .Set (1 )
}
if !(d .ReadOutboxMaxID == 0 ) {
d .Flags .Set (2 )
}
}
func (d *MessagesDiscussionMessage ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.discussionMessage#a6341782 as nil" )
}
b .PutID (MessagesDiscussionMessageTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDiscussionMessage ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.discussionMessage#a6341782 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field flags: %w" , err )
}
b .PutVectorHeader (len (d .Messages ))
for idx , v := range d .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field messages element with index %d: %w" , idx , err )
}
}
if d .Flags .Has (0 ) {
b .PutInt (d .MaxID )
}
if d .Flags .Has (1 ) {
b .PutInt (d .ReadInboxMaxID )
}
if d .Flags .Has (2 ) {
b .PutInt (d .ReadOutboxMaxID )
}
b .PutInt (d .UnreadCount )
b .PutVectorHeader (len (d .Chats ))
for idx , v := range d .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Users ))
for idx , v := range d .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.discussionMessage#a6341782: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *MessagesDiscussionMessage ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.discussionMessage#a6341782 to nil" )
}
if err := b .ConsumeID (MessagesDiscussionMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDiscussionMessage ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.discussionMessage#a6341782 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field flags: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field messages: %w" , err )
}
if headerLen > 0 {
d .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field messages: %w" , err )
}
d .Messages = append (d .Messages , value )
}
}
if d .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field max_id: %w" , err )
}
d .MaxID = value
}
if d .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field read_inbox_max_id: %w" , err )
}
d .ReadInboxMaxID = value
}
if d .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field read_outbox_max_id: %w" , err )
}
d .ReadOutboxMaxID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field unread_count: %w" , err )
}
d .UnreadCount = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field chats: %w" , err )
}
if headerLen > 0 {
d .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field chats: %w" , err )
}
d .Chats = append (d .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field users: %w" , err )
}
if headerLen > 0 {
d .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.discussionMessage#a6341782: field users: %w" , err )
}
d .Users = append (d .Users , value )
}
}
return nil
}
func (d *MessagesDiscussionMessage ) GetMessages () (value []MessageClass ) {
if d == nil {
return
}
return d .Messages
}
func (d *MessagesDiscussionMessage ) SetMaxID (value int ) {
d .Flags .Set (0 )
d .MaxID = value
}
func (d *MessagesDiscussionMessage ) GetMaxID () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (0 ) {
return value , false
}
return d .MaxID , true
}
func (d *MessagesDiscussionMessage ) SetReadInboxMaxID (value int ) {
d .Flags .Set (1 )
d .ReadInboxMaxID = value
}
func (d *MessagesDiscussionMessage ) GetReadInboxMaxID () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (1 ) {
return value , false
}
return d .ReadInboxMaxID , true
}
func (d *MessagesDiscussionMessage ) SetReadOutboxMaxID (value int ) {
d .Flags .Set (2 )
d .ReadOutboxMaxID = value
}
func (d *MessagesDiscussionMessage ) GetReadOutboxMaxID () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (2 ) {
return value , false
}
return d .ReadOutboxMaxID , true
}
func (d *MessagesDiscussionMessage ) GetUnreadCount () (value int ) {
if d == nil {
return
}
return d .UnreadCount
}
func (d *MessagesDiscussionMessage ) GetChats () (value []ChatClass ) {
if d == nil {
return
}
return d .Chats
}
func (d *MessagesDiscussionMessage ) GetUsers () (value []UserClass ) {
if d == nil {
return
}
return d .Users
}
func (d *MessagesDiscussionMessage ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (d .Messages )
}
func (d *MessagesDiscussionMessage ) MapChats () (value ChatClassArray ) {
return ChatClassArray (d .Chats )
}
func (d *MessagesDiscussionMessage ) MapUsers () (value UserClassArray ) {
return UserClassArray (d .Users )
}
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 .