-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
tl_message_replies_gen.go
478 lines (440 loc) · 11 KB
/
tl_message_replies_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
// Code generated by gotdgen, DO NOT EDIT.
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"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// MessageReplies represents TL type `messageReplies#83d60fc2`.
// Info about the comment section of a channel post, or a simple message thread¹
//
// Links:
// 1. https://core.telegram.org/api/threads
//
// See https://core.telegram.org/constructor/messageReplies for reference.
type MessageReplies struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this constructor contains information about the comment section of a channel
// post, or a simple message thread¹
//
// Links:
// 1) https://core.telegram.org/api/threads
Comments bool
// Contains the total number of replies in this thread or comment section.
Replies int
// PTS¹ of the message that started this thread.
//
// Links:
// 1) https://core.telegram.org/api/updates
RepliesPts int
// For channel post comments, contains information about the last few comment posters for
// a specific thread, to show a small list of commenter profile pictures in client
// previews.
//
// Use SetRecentRepliers and GetRecentRepliers helpers.
RecentRepliers []PeerClass
// For channel post comments, contains the ID of the associated discussion supergroup¹
//
// Links:
// 1) https://core.telegram.org/api/discussion
//
// Use SetChannelID and GetChannelID helpers.
ChannelID int64
// ID of the latest message in this thread or comment section.
//
// Use SetMaxID and GetMaxID helpers.
MaxID int
// Contains the ID of the latest read message in this thread or comment section.
//
// Use SetReadMaxID and GetReadMaxID helpers.
ReadMaxID int
}
// MessageRepliesTypeID is TL type id of MessageReplies.
const MessageRepliesTypeID = 0x83d60fc2
// Ensuring interfaces in compile-time for MessageReplies.
var (
_ bin.Encoder = &MessageReplies{}
_ bin.Decoder = &MessageReplies{}
_ bin.BareEncoder = &MessageReplies{}
_ bin.BareDecoder = &MessageReplies{}
)
func (m *MessageReplies) Zero() bool {
if m == nil {
return true
}
if !(m.Flags.Zero()) {
return false
}
if !(m.Comments == false) {
return false
}
if !(m.Replies == 0) {
return false
}
if !(m.RepliesPts == 0) {
return false
}
if !(m.RecentRepliers == nil) {
return false
}
if !(m.ChannelID == 0) {
return false
}
if !(m.MaxID == 0) {
return false
}
if !(m.ReadMaxID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (m *MessageReplies) String() string {
if m == nil {
return "MessageReplies(nil)"
}
type Alias MessageReplies
return fmt.Sprintf("MessageReplies%+v", Alias(*m))
}
// FillFrom fills MessageReplies from given interface.
func (m *MessageReplies) FillFrom(from interface {
GetComments() (value bool)
GetReplies() (value int)
GetRepliesPts() (value int)
GetRecentRepliers() (value []PeerClass, ok bool)
GetChannelID() (value int64, ok bool)
GetMaxID() (value int, ok bool)
GetReadMaxID() (value int, ok bool)
}) {
m.Comments = from.GetComments()
m.Replies = from.GetReplies()
m.RepliesPts = from.GetRepliesPts()
if val, ok := from.GetRecentRepliers(); ok {
m.RecentRepliers = val
}
if val, ok := from.GetChannelID(); ok {
m.ChannelID = val
}
if val, ok := from.GetMaxID(); ok {
m.MaxID = val
}
if val, ok := from.GetReadMaxID(); ok {
m.ReadMaxID = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessageReplies) TypeID() uint32 {
return MessageRepliesTypeID
}
// TypeName returns name of type in TL schema.
func (*MessageReplies) TypeName() string {
return "messageReplies"
}
// TypeInfo returns info about TL type.
func (m *MessageReplies) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "messageReplies",
ID: MessageRepliesTypeID,
}
if m == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Comments",
SchemaName: "comments",
Null: !m.Flags.Has(0),
},
{
Name: "Replies",
SchemaName: "replies",
},
{
Name: "RepliesPts",
SchemaName: "replies_pts",
},
{
Name: "RecentRepliers",
SchemaName: "recent_repliers",
Null: !m.Flags.Has(1),
},
{
Name: "ChannelID",
SchemaName: "channel_id",
Null: !m.Flags.Has(0),
},
{
Name: "MaxID",
SchemaName: "max_id",
Null: !m.Flags.Has(2),
},
{
Name: "ReadMaxID",
SchemaName: "read_max_id",
Null: !m.Flags.Has(3),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (m *MessageReplies) SetFlags() {
if !(m.Comments == false) {
m.Flags.Set(0)
}
if !(m.RecentRepliers == nil) {
m.Flags.Set(1)
}
if !(m.ChannelID == 0) {
m.Flags.Set(0)
}
if !(m.MaxID == 0) {
m.Flags.Set(2)
}
if !(m.ReadMaxID == 0) {
m.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (m *MessageReplies) Encode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode messageReplies#83d60fc2 as nil")
}
b.PutID(MessageRepliesTypeID)
return m.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (m *MessageReplies) EncodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't encode messageReplies#83d60fc2 as nil")
}
m.SetFlags()
if err := m.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode messageReplies#83d60fc2: field flags: %w", err)
}
b.PutInt(m.Replies)
b.PutInt(m.RepliesPts)
if m.Flags.Has(1) {
b.PutVectorHeader(len(m.RecentRepliers))
for idx, v := range m.RecentRepliers {
if v == nil {
return fmt.Errorf("unable to encode messageReplies#83d60fc2: field recent_repliers element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode messageReplies#83d60fc2: field recent_repliers element with index %d: %w", idx, err)
}
}
}
if m.Flags.Has(0) {
b.PutLong(m.ChannelID)
}
if m.Flags.Has(2) {
b.PutInt(m.MaxID)
}
if m.Flags.Has(3) {
b.PutInt(m.ReadMaxID)
}
return nil
}
// Decode implements bin.Decoder.
func (m *MessageReplies) Decode(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode messageReplies#83d60fc2 to nil")
}
if err := b.ConsumeID(MessageRepliesTypeID); err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: %w", err)
}
return m.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (m *MessageReplies) DecodeBare(b *bin.Buffer) error {
if m == nil {
return fmt.Errorf("can't decode messageReplies#83d60fc2 to nil")
}
{
if err := m.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field flags: %w", err)
}
}
m.Comments = m.Flags.Has(0)
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field replies: %w", err)
}
m.Replies = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field replies_pts: %w", err)
}
m.RepliesPts = value
}
if m.Flags.Has(1) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field recent_repliers: %w", err)
}
if headerLen > 0 {
m.RecentRepliers = make([]PeerClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field recent_repliers: %w", err)
}
m.RecentRepliers = append(m.RecentRepliers, value)
}
}
if m.Flags.Has(0) {
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field channel_id: %w", err)
}
m.ChannelID = value
}
if m.Flags.Has(2) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field max_id: %w", err)
}
m.MaxID = value
}
if m.Flags.Has(3) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode messageReplies#83d60fc2: field read_max_id: %w", err)
}
m.ReadMaxID = value
}
return nil
}
// SetComments sets value of Comments conditional field.
func (m *MessageReplies) SetComments(value bool) {
if value {
m.Flags.Set(0)
m.Comments = true
} else {
m.Flags.Unset(0)
m.Comments = false
}
}
// GetComments returns value of Comments conditional field.
func (m *MessageReplies) GetComments() (value bool) {
if m == nil {
return
}
return m.Flags.Has(0)
}
// GetReplies returns value of Replies field.
func (m *MessageReplies) GetReplies() (value int) {
if m == nil {
return
}
return m.Replies
}
// GetRepliesPts returns value of RepliesPts field.
func (m *MessageReplies) GetRepliesPts() (value int) {
if m == nil {
return
}
return m.RepliesPts
}
// SetRecentRepliers sets value of RecentRepliers conditional field.
func (m *MessageReplies) SetRecentRepliers(value []PeerClass) {
m.Flags.Set(1)
m.RecentRepliers = value
}
// GetRecentRepliers returns value of RecentRepliers conditional field and
// boolean which is true if field was set.
func (m *MessageReplies) GetRecentRepliers() (value []PeerClass, ok bool) {
if m == nil {
return
}
if !m.Flags.Has(1) {
return value, false
}
return m.RecentRepliers, true
}
// SetChannelID sets value of ChannelID conditional field.
func (m *MessageReplies) SetChannelID(value int64) {
m.Flags.Set(0)
m.ChannelID = value
}
// GetChannelID returns value of ChannelID conditional field and
// boolean which is true if field was set.
func (m *MessageReplies) GetChannelID() (value int64, ok bool) {
if m == nil {
return
}
if !m.Flags.Has(0) {
return value, false
}
return m.ChannelID, true
}
// SetMaxID sets value of MaxID conditional field.
func (m *MessageReplies) SetMaxID(value int) {
m.Flags.Set(2)
m.MaxID = value
}
// GetMaxID returns value of MaxID conditional field and
// boolean which is true if field was set.
func (m *MessageReplies) GetMaxID() (value int, ok bool) {
if m == nil {
return
}
if !m.Flags.Has(2) {
return value, false
}
return m.MaxID, true
}
// SetReadMaxID sets value of ReadMaxID conditional field.
func (m *MessageReplies) SetReadMaxID(value int) {
m.Flags.Set(3)
m.ReadMaxID = value
}
// GetReadMaxID returns value of ReadMaxID conditional field and
// boolean which is true if field was set.
func (m *MessageReplies) GetReadMaxID() (value int, ok bool) {
if m == nil {
return
}
if !m.Flags.Has(3) {
return value, false
}
return m.ReadMaxID, true
}
// MapRecentRepliers returns field RecentRepliers wrapped in PeerClassArray helper.
func (m *MessageReplies) MapRecentRepliers() (value PeerClassArray, ok bool) {
if !m.Flags.Has(1) {
return value, false
}
return PeerClassArray(m.RecentRepliers), true
}