-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
tl_chat_invite_exported_gen.go
630 lines (583 loc) · 13.5 KB
/
tl_chat_invite_exported_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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
// 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{}
)
// ChatInviteExported represents TL type `chatInviteExported#ab4a819`.
// Exported chat invite
//
// See https://core.telegram.org/constructor/chatInviteExported for reference.
type ChatInviteExported struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether this chat invite was revoked
Revoked bool
// Whether this chat invite has no expiration
Permanent bool
// RequestNeeded field of ChatInviteExported.
RequestNeeded bool
// Chat invitation link
Link string
// ID of the admin that created this chat invite
AdminID int64
// When was this chat invite created
Date int
// When was this chat invite last modified
//
// Use SetStartDate and GetStartDate helpers.
StartDate int
// When does this chat invite expire
//
// Use SetExpireDate and GetExpireDate helpers.
ExpireDate int
// Maximum number of users that can join using this link
//
// Use SetUsageLimit and GetUsageLimit helpers.
UsageLimit int
// How many users joined using this link
//
// Use SetUsage and GetUsage helpers.
Usage int
// Requested field of ChatInviteExported.
//
// Use SetRequested and GetRequested helpers.
Requested int
// Title field of ChatInviteExported.
//
// Use SetTitle and GetTitle helpers.
Title string
}
// ChatInviteExportedTypeID is TL type id of ChatInviteExported.
const ChatInviteExportedTypeID = 0xab4a819
// Ensuring interfaces in compile-time for ChatInviteExported.
var (
_ bin.Encoder = &ChatInviteExported{}
_ bin.Decoder = &ChatInviteExported{}
_ bin.BareEncoder = &ChatInviteExported{}
_ bin.BareDecoder = &ChatInviteExported{}
)
func (c *ChatInviteExported) Zero() bool {
if c == nil {
return true
}
if !(c.Flags.Zero()) {
return false
}
if !(c.Revoked == false) {
return false
}
if !(c.Permanent == false) {
return false
}
if !(c.RequestNeeded == false) {
return false
}
if !(c.Link == "") {
return false
}
if !(c.AdminID == 0) {
return false
}
if !(c.Date == 0) {
return false
}
if !(c.StartDate == 0) {
return false
}
if !(c.ExpireDate == 0) {
return false
}
if !(c.UsageLimit == 0) {
return false
}
if !(c.Usage == 0) {
return false
}
if !(c.Requested == 0) {
return false
}
if !(c.Title == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatInviteExported) String() string {
if c == nil {
return "ChatInviteExported(nil)"
}
type Alias ChatInviteExported
return fmt.Sprintf("ChatInviteExported%+v", Alias(*c))
}
// FillFrom fills ChatInviteExported from given interface.
func (c *ChatInviteExported) FillFrom(from interface {
GetRevoked() (value bool)
GetPermanent() (value bool)
GetRequestNeeded() (value bool)
GetLink() (value string)
GetAdminID() (value int64)
GetDate() (value int)
GetStartDate() (value int, ok bool)
GetExpireDate() (value int, ok bool)
GetUsageLimit() (value int, ok bool)
GetUsage() (value int, ok bool)
GetRequested() (value int, ok bool)
GetTitle() (value string, ok bool)
}) {
c.Revoked = from.GetRevoked()
c.Permanent = from.GetPermanent()
c.RequestNeeded = from.GetRequestNeeded()
c.Link = from.GetLink()
c.AdminID = from.GetAdminID()
c.Date = from.GetDate()
if val, ok := from.GetStartDate(); ok {
c.StartDate = val
}
if val, ok := from.GetExpireDate(); ok {
c.ExpireDate = val
}
if val, ok := from.GetUsageLimit(); ok {
c.UsageLimit = val
}
if val, ok := from.GetUsage(); ok {
c.Usage = val
}
if val, ok := from.GetRequested(); ok {
c.Requested = val
}
if val, ok := from.GetTitle(); ok {
c.Title = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatInviteExported) TypeID() uint32 {
return ChatInviteExportedTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatInviteExported) TypeName() string {
return "chatInviteExported"
}
// TypeInfo returns info about TL type.
func (c *ChatInviteExported) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatInviteExported",
ID: ChatInviteExportedTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Revoked",
SchemaName: "revoked",
Null: !c.Flags.Has(0),
},
{
Name: "Permanent",
SchemaName: "permanent",
Null: !c.Flags.Has(5),
},
{
Name: "RequestNeeded",
SchemaName: "request_needed",
Null: !c.Flags.Has(6),
},
{
Name: "Link",
SchemaName: "link",
},
{
Name: "AdminID",
SchemaName: "admin_id",
},
{
Name: "Date",
SchemaName: "date",
},
{
Name: "StartDate",
SchemaName: "start_date",
Null: !c.Flags.Has(4),
},
{
Name: "ExpireDate",
SchemaName: "expire_date",
Null: !c.Flags.Has(1),
},
{
Name: "UsageLimit",
SchemaName: "usage_limit",
Null: !c.Flags.Has(2),
},
{
Name: "Usage",
SchemaName: "usage",
Null: !c.Flags.Has(3),
},
{
Name: "Requested",
SchemaName: "requested",
Null: !c.Flags.Has(7),
},
{
Name: "Title",
SchemaName: "title",
Null: !c.Flags.Has(8),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (c *ChatInviteExported) SetFlags() {
if !(c.Revoked == false) {
c.Flags.Set(0)
}
if !(c.Permanent == false) {
c.Flags.Set(5)
}
if !(c.RequestNeeded == false) {
c.Flags.Set(6)
}
if !(c.StartDate == 0) {
c.Flags.Set(4)
}
if !(c.ExpireDate == 0) {
c.Flags.Set(1)
}
if !(c.UsageLimit == 0) {
c.Flags.Set(2)
}
if !(c.Usage == 0) {
c.Flags.Set(3)
}
if !(c.Requested == 0) {
c.Flags.Set(7)
}
if !(c.Title == "") {
c.Flags.Set(8)
}
}
// Encode implements bin.Encoder.
func (c *ChatInviteExported) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatInviteExported#ab4a819 as nil")
}
b.PutID(ChatInviteExportedTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatInviteExported) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatInviteExported#ab4a819 as nil")
}
c.SetFlags()
if err := c.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode chatInviteExported#ab4a819: field flags: %w", err)
}
b.PutString(c.Link)
b.PutLong(c.AdminID)
b.PutInt(c.Date)
if c.Flags.Has(4) {
b.PutInt(c.StartDate)
}
if c.Flags.Has(1) {
b.PutInt(c.ExpireDate)
}
if c.Flags.Has(2) {
b.PutInt(c.UsageLimit)
}
if c.Flags.Has(3) {
b.PutInt(c.Usage)
}
if c.Flags.Has(7) {
b.PutInt(c.Requested)
}
if c.Flags.Has(8) {
b.PutString(c.Title)
}
return nil
}
// Decode implements bin.Decoder.
func (c *ChatInviteExported) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatInviteExported#ab4a819 to nil")
}
if err := b.ConsumeID(ChatInviteExportedTypeID); err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatInviteExported) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatInviteExported#ab4a819 to nil")
}
{
if err := c.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field flags: %w", err)
}
}
c.Revoked = c.Flags.Has(0)
c.Permanent = c.Flags.Has(5)
c.RequestNeeded = c.Flags.Has(6)
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field link: %w", err)
}
c.Link = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field admin_id: %w", err)
}
c.AdminID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field date: %w", err)
}
c.Date = value
}
if c.Flags.Has(4) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field start_date: %w", err)
}
c.StartDate = value
}
if c.Flags.Has(1) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field expire_date: %w", err)
}
c.ExpireDate = value
}
if c.Flags.Has(2) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field usage_limit: %w", err)
}
c.UsageLimit = value
}
if c.Flags.Has(3) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field usage: %w", err)
}
c.Usage = value
}
if c.Flags.Has(7) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field requested: %w", err)
}
c.Requested = value
}
if c.Flags.Has(8) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chatInviteExported#ab4a819: field title: %w", err)
}
c.Title = value
}
return nil
}
// SetRevoked sets value of Revoked conditional field.
func (c *ChatInviteExported) SetRevoked(value bool) {
if value {
c.Flags.Set(0)
c.Revoked = true
} else {
c.Flags.Unset(0)
c.Revoked = false
}
}
// GetRevoked returns value of Revoked conditional field.
func (c *ChatInviteExported) GetRevoked() (value bool) {
if c == nil {
return
}
return c.Flags.Has(0)
}
// SetPermanent sets value of Permanent conditional field.
func (c *ChatInviteExported) SetPermanent(value bool) {
if value {
c.Flags.Set(5)
c.Permanent = true
} else {
c.Flags.Unset(5)
c.Permanent = false
}
}
// GetPermanent returns value of Permanent conditional field.
func (c *ChatInviteExported) GetPermanent() (value bool) {
if c == nil {
return
}
return c.Flags.Has(5)
}
// SetRequestNeeded sets value of RequestNeeded conditional field.
func (c *ChatInviteExported) SetRequestNeeded(value bool) {
if value {
c.Flags.Set(6)
c.RequestNeeded = true
} else {
c.Flags.Unset(6)
c.RequestNeeded = false
}
}
// GetRequestNeeded returns value of RequestNeeded conditional field.
func (c *ChatInviteExported) GetRequestNeeded() (value bool) {
if c == nil {
return
}
return c.Flags.Has(6)
}
// GetLink returns value of Link field.
func (c *ChatInviteExported) GetLink() (value string) {
if c == nil {
return
}
return c.Link
}
// GetAdminID returns value of AdminID field.
func (c *ChatInviteExported) GetAdminID() (value int64) {
if c == nil {
return
}
return c.AdminID
}
// GetDate returns value of Date field.
func (c *ChatInviteExported) GetDate() (value int) {
if c == nil {
return
}
return c.Date
}
// SetStartDate sets value of StartDate conditional field.
func (c *ChatInviteExported) SetStartDate(value int) {
c.Flags.Set(4)
c.StartDate = value
}
// GetStartDate returns value of StartDate conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetStartDate() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(4) {
return value, false
}
return c.StartDate, true
}
// SetExpireDate sets value of ExpireDate conditional field.
func (c *ChatInviteExported) SetExpireDate(value int) {
c.Flags.Set(1)
c.ExpireDate = value
}
// GetExpireDate returns value of ExpireDate conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetExpireDate() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(1) {
return value, false
}
return c.ExpireDate, true
}
// SetUsageLimit sets value of UsageLimit conditional field.
func (c *ChatInviteExported) SetUsageLimit(value int) {
c.Flags.Set(2)
c.UsageLimit = value
}
// GetUsageLimit returns value of UsageLimit conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetUsageLimit() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(2) {
return value, false
}
return c.UsageLimit, true
}
// SetUsage sets value of Usage conditional field.
func (c *ChatInviteExported) SetUsage(value int) {
c.Flags.Set(3)
c.Usage = value
}
// GetUsage returns value of Usage conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetUsage() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(3) {
return value, false
}
return c.Usage, true
}
// SetRequested sets value of Requested conditional field.
func (c *ChatInviteExported) SetRequested(value int) {
c.Flags.Set(7)
c.Requested = value
}
// GetRequested returns value of Requested conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetRequested() (value int, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(7) {
return value, false
}
return c.Requested, true
}
// SetTitle sets value of Title conditional field.
func (c *ChatInviteExported) SetTitle(value string) {
c.Flags.Set(8)
c.Title = value
}
// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func (c *ChatInviteExported) GetTitle() (value string, ok bool) {
if c == nil {
return
}
if !c.Flags.Has(8) {
return value, false
}
return c.Title, true
}