-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
tl_dialog_gen.go
1170 lines (1084 loc) · 26.5 KB
/
tl_dialog_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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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{}
)
// Dialog represents TL type `dialog#d58a08c6`.
// Chat
//
// See https://core.telegram.org/constructor/dialog for reference.
type Dialog struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Is the dialog pinned
Pinned bool
// Whether the chat was manually marked as unread
UnreadMark bool
// Users may also choose to display messages from all topics of a forum¹ as if they were
// sent to a normal group, using a "View as messages" setting in the local client. This
// setting only affects the current account, and is synced to other logged in sessions
// using the channels.toggleViewForumAsMessages² method; invoking this method will
// update the value of this flag.
//
// Links:
// 1) https://core.telegram.org/api/forum
// 2) https://core.telegram.org/method/channels.toggleViewForumAsMessages
ViewForumAsMessages bool
// The chat
Peer PeerClass
// The latest message ID
TopMessage int
// Position up to which all incoming messages are read.
ReadInboxMaxID int
// Position up to which all outgoing messages are read.
ReadOutboxMaxID int
// Number of unread messages
UnreadCount int
// Number of unread mentions¹
//
// Links:
// 1) https://core.telegram.org/api/mentions
UnreadMentionsCount int
// Number of unread reactions to messages you sent
UnreadReactionsCount int
// Notification settings
NotifySettings PeerNotifySettings
// PTS¹
//
// Links:
// 1) https://core.telegram.org/api/updates
//
// Use SetPts and GetPts helpers.
Pts int
// Message draft¹
//
// Links:
// 1) https://core.telegram.org/api/drafts
//
// Use SetDraft and GetDraft helpers.
Draft DraftMessageClass
// Peer folder ID, for more info click here¹
//
// Links:
// 1) https://core.telegram.org/api/folders#peer-folders
//
// Use SetFolderID and GetFolderID helpers.
FolderID int
// Time-to-live of all messages sent in this dialog
//
// Use SetTTLPeriod and GetTTLPeriod helpers.
TTLPeriod int
}
// DialogTypeID is TL type id of Dialog.
const DialogTypeID = 0xd58a08c6
// construct implements constructor of DialogClass.
func (d Dialog) construct() DialogClass { return &d }
// Ensuring interfaces in compile-time for Dialog.
var (
_ bin.Encoder = &Dialog{}
_ bin.Decoder = &Dialog{}
_ bin.BareEncoder = &Dialog{}
_ bin.BareDecoder = &Dialog{}
_ DialogClass = &Dialog{}
)
func (d *Dialog) Zero() bool {
if d == nil {
return true
}
if !(d.Flags.Zero()) {
return false
}
if !(d.Pinned == false) {
return false
}
if !(d.UnreadMark == false) {
return false
}
if !(d.ViewForumAsMessages == false) {
return false
}
if !(d.Peer == nil) {
return false
}
if !(d.TopMessage == 0) {
return false
}
if !(d.ReadInboxMaxID == 0) {
return false
}
if !(d.ReadOutboxMaxID == 0) {
return false
}
if !(d.UnreadCount == 0) {
return false
}
if !(d.UnreadMentionsCount == 0) {
return false
}
if !(d.UnreadReactionsCount == 0) {
return false
}
if !(d.NotifySettings.Zero()) {
return false
}
if !(d.Pts == 0) {
return false
}
if !(d.Draft == nil) {
return false
}
if !(d.FolderID == 0) {
return false
}
if !(d.TTLPeriod == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (d *Dialog) String() string {
if d == nil {
return "Dialog(nil)"
}
type Alias Dialog
return fmt.Sprintf("Dialog%+v", Alias(*d))
}
// FillFrom fills Dialog from given interface.
func (d *Dialog) FillFrom(from interface {
GetPinned() (value bool)
GetUnreadMark() (value bool)
GetViewForumAsMessages() (value bool)
GetPeer() (value PeerClass)
GetTopMessage() (value int)
GetReadInboxMaxID() (value int)
GetReadOutboxMaxID() (value int)
GetUnreadCount() (value int)
GetUnreadMentionsCount() (value int)
GetUnreadReactionsCount() (value int)
GetNotifySettings() (value PeerNotifySettings)
GetPts() (value int, ok bool)
GetDraft() (value DraftMessageClass, ok bool)
GetFolderID() (value int, ok bool)
GetTTLPeriod() (value int, ok bool)
}) {
d.Pinned = from.GetPinned()
d.UnreadMark = from.GetUnreadMark()
d.ViewForumAsMessages = from.GetViewForumAsMessages()
d.Peer = from.GetPeer()
d.TopMessage = from.GetTopMessage()
d.ReadInboxMaxID = from.GetReadInboxMaxID()
d.ReadOutboxMaxID = from.GetReadOutboxMaxID()
d.UnreadCount = from.GetUnreadCount()
d.UnreadMentionsCount = from.GetUnreadMentionsCount()
d.UnreadReactionsCount = from.GetUnreadReactionsCount()
d.NotifySettings = from.GetNotifySettings()
if val, ok := from.GetPts(); ok {
d.Pts = val
}
if val, ok := from.GetDraft(); ok {
d.Draft = val
}
if val, ok := from.GetFolderID(); ok {
d.FolderID = val
}
if val, ok := from.GetTTLPeriod(); ok {
d.TTLPeriod = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*Dialog) TypeID() uint32 {
return DialogTypeID
}
// TypeName returns name of type in TL schema.
func (*Dialog) TypeName() string {
return "dialog"
}
// TypeInfo returns info about TL type.
func (d *Dialog) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "dialog",
ID: DialogTypeID,
}
if d == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Pinned",
SchemaName: "pinned",
Null: !d.Flags.Has(2),
},
{
Name: "UnreadMark",
SchemaName: "unread_mark",
Null: !d.Flags.Has(3),
},
{
Name: "ViewForumAsMessages",
SchemaName: "view_forum_as_messages",
Null: !d.Flags.Has(6),
},
{
Name: "Peer",
SchemaName: "peer",
},
{
Name: "TopMessage",
SchemaName: "top_message",
},
{
Name: "ReadInboxMaxID",
SchemaName: "read_inbox_max_id",
},
{
Name: "ReadOutboxMaxID",
SchemaName: "read_outbox_max_id",
},
{
Name: "UnreadCount",
SchemaName: "unread_count",
},
{
Name: "UnreadMentionsCount",
SchemaName: "unread_mentions_count",
},
{
Name: "UnreadReactionsCount",
SchemaName: "unread_reactions_count",
},
{
Name: "NotifySettings",
SchemaName: "notify_settings",
},
{
Name: "Pts",
SchemaName: "pts",
Null: !d.Flags.Has(0),
},
{
Name: "Draft",
SchemaName: "draft",
Null: !d.Flags.Has(1),
},
{
Name: "FolderID",
SchemaName: "folder_id",
Null: !d.Flags.Has(4),
},
{
Name: "TTLPeriod",
SchemaName: "ttl_period",
Null: !d.Flags.Has(5),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (d *Dialog) SetFlags() {
if !(d.Pinned == false) {
d.Flags.Set(2)
}
if !(d.UnreadMark == false) {
d.Flags.Set(3)
}
if !(d.ViewForumAsMessages == false) {
d.Flags.Set(6)
}
if !(d.Pts == 0) {
d.Flags.Set(0)
}
if !(d.Draft == nil) {
d.Flags.Set(1)
}
if !(d.FolderID == 0) {
d.Flags.Set(4)
}
if !(d.TTLPeriod == 0) {
d.Flags.Set(5)
}
}
// Encode implements bin.Encoder.
func (d *Dialog) Encode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode dialog#d58a08c6 as nil")
}
b.PutID(DialogTypeID)
return d.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (d *Dialog) EncodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode dialog#d58a08c6 as nil")
}
d.SetFlags()
if err := d.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field flags: %w", err)
}
if d.Peer == nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field peer is nil")
}
if err := d.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field peer: %w", err)
}
b.PutInt(d.TopMessage)
b.PutInt(d.ReadInboxMaxID)
b.PutInt(d.ReadOutboxMaxID)
b.PutInt(d.UnreadCount)
b.PutInt(d.UnreadMentionsCount)
b.PutInt(d.UnreadReactionsCount)
if err := d.NotifySettings.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field notify_settings: %w", err)
}
if d.Flags.Has(0) {
b.PutInt(d.Pts)
}
if d.Flags.Has(1) {
if d.Draft == nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field draft is nil")
}
if err := d.Draft.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialog#d58a08c6: field draft: %w", err)
}
}
if d.Flags.Has(4) {
b.PutInt(d.FolderID)
}
if d.Flags.Has(5) {
b.PutInt(d.TTLPeriod)
}
return nil
}
// Decode implements bin.Decoder.
func (d *Dialog) Decode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode dialog#d58a08c6 to nil")
}
if err := b.ConsumeID(DialogTypeID); err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: %w", err)
}
return d.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (d *Dialog) DecodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode dialog#d58a08c6 to nil")
}
{
if err := d.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field flags: %w", err)
}
}
d.Pinned = d.Flags.Has(2)
d.UnreadMark = d.Flags.Has(3)
d.ViewForumAsMessages = d.Flags.Has(6)
{
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field peer: %w", err)
}
d.Peer = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field top_message: %w", err)
}
d.TopMessage = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field read_inbox_max_id: %w", err)
}
d.ReadInboxMaxID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field read_outbox_max_id: %w", err)
}
d.ReadOutboxMaxID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_count: %w", err)
}
d.UnreadCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_mentions_count: %w", err)
}
d.UnreadMentionsCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_reactions_count: %w", err)
}
d.UnreadReactionsCount = value
}
{
if err := d.NotifySettings.Decode(b); err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field notify_settings: %w", err)
}
}
if d.Flags.Has(0) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field pts: %w", err)
}
d.Pts = value
}
if d.Flags.Has(1) {
value, err := DecodeDraftMessage(b)
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field draft: %w", err)
}
d.Draft = value
}
if d.Flags.Has(4) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field folder_id: %w", err)
}
d.FolderID = value
}
if d.Flags.Has(5) {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialog#d58a08c6: field ttl_period: %w", err)
}
d.TTLPeriod = value
}
return nil
}
// SetPinned sets value of Pinned conditional field.
func (d *Dialog) SetPinned(value bool) {
if value {
d.Flags.Set(2)
d.Pinned = true
} else {
d.Flags.Unset(2)
d.Pinned = false
}
}
// GetPinned returns value of Pinned conditional field.
func (d *Dialog) GetPinned() (value bool) {
if d == nil {
return
}
return d.Flags.Has(2)
}
// SetUnreadMark sets value of UnreadMark conditional field.
func (d *Dialog) SetUnreadMark(value bool) {
if value {
d.Flags.Set(3)
d.UnreadMark = true
} else {
d.Flags.Unset(3)
d.UnreadMark = false
}
}
// GetUnreadMark returns value of UnreadMark conditional field.
func (d *Dialog) GetUnreadMark() (value bool) {
if d == nil {
return
}
return d.Flags.Has(3)
}
// SetViewForumAsMessages sets value of ViewForumAsMessages conditional field.
func (d *Dialog) SetViewForumAsMessages(value bool) {
if value {
d.Flags.Set(6)
d.ViewForumAsMessages = true
} else {
d.Flags.Unset(6)
d.ViewForumAsMessages = false
}
}
// GetViewForumAsMessages returns value of ViewForumAsMessages conditional field.
func (d *Dialog) GetViewForumAsMessages() (value bool) {
if d == nil {
return
}
return d.Flags.Has(6)
}
// GetPeer returns value of Peer field.
func (d *Dialog) GetPeer() (value PeerClass) {
if d == nil {
return
}
return d.Peer
}
// GetTopMessage returns value of TopMessage field.
func (d *Dialog) GetTopMessage() (value int) {
if d == nil {
return
}
return d.TopMessage
}
// GetReadInboxMaxID returns value of ReadInboxMaxID field.
func (d *Dialog) GetReadInboxMaxID() (value int) {
if d == nil {
return
}
return d.ReadInboxMaxID
}
// GetReadOutboxMaxID returns value of ReadOutboxMaxID field.
func (d *Dialog) GetReadOutboxMaxID() (value int) {
if d == nil {
return
}
return d.ReadOutboxMaxID
}
// GetUnreadCount returns value of UnreadCount field.
func (d *Dialog) GetUnreadCount() (value int) {
if d == nil {
return
}
return d.UnreadCount
}
// GetUnreadMentionsCount returns value of UnreadMentionsCount field.
func (d *Dialog) GetUnreadMentionsCount() (value int) {
if d == nil {
return
}
return d.UnreadMentionsCount
}
// GetUnreadReactionsCount returns value of UnreadReactionsCount field.
func (d *Dialog) GetUnreadReactionsCount() (value int) {
if d == nil {
return
}
return d.UnreadReactionsCount
}
// GetNotifySettings returns value of NotifySettings field.
func (d *Dialog) GetNotifySettings() (value PeerNotifySettings) {
if d == nil {
return
}
return d.NotifySettings
}
// SetPts sets value of Pts conditional field.
func (d *Dialog) SetPts(value int) {
d.Flags.Set(0)
d.Pts = value
}
// GetPts returns value of Pts conditional field and
// boolean which is true if field was set.
func (d *Dialog) GetPts() (value int, ok bool) {
if d == nil {
return
}
if !d.Flags.Has(0) {
return value, false
}
return d.Pts, true
}
// SetDraft sets value of Draft conditional field.
func (d *Dialog) SetDraft(value DraftMessageClass) {
d.Flags.Set(1)
d.Draft = value
}
// GetDraft returns value of Draft conditional field and
// boolean which is true if field was set.
func (d *Dialog) GetDraft() (value DraftMessageClass, ok bool) {
if d == nil {
return
}
if !d.Flags.Has(1) {
return value, false
}
return d.Draft, true
}
// SetFolderID sets value of FolderID conditional field.
func (d *Dialog) SetFolderID(value int) {
d.Flags.Set(4)
d.FolderID = value
}
// GetFolderID returns value of FolderID conditional field and
// boolean which is true if field was set.
func (d *Dialog) GetFolderID() (value int, ok bool) {
if d == nil {
return
}
if !d.Flags.Has(4) {
return value, false
}
return d.FolderID, true
}
// SetTTLPeriod sets value of TTLPeriod conditional field.
func (d *Dialog) SetTTLPeriod(value int) {
d.Flags.Set(5)
d.TTLPeriod = value
}
// GetTTLPeriod returns value of TTLPeriod conditional field and
// boolean which is true if field was set.
func (d *Dialog) GetTTLPeriod() (value int, ok bool) {
if d == nil {
return
}
if !d.Flags.Has(5) {
return value, false
}
return d.TTLPeriod, true
}
// DialogFolder represents TL type `dialogFolder#71bd134c`.
// Dialog in folder
//
// See https://core.telegram.org/constructor/dialogFolder for reference.
type DialogFolder struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Is this folder pinned
Pinned bool
// The folder
Folder Folder
// Peer in folder
Peer PeerClass
// Latest message ID of dialog
TopMessage int
// Number of unread muted peers in folder
UnreadMutedPeersCount int
// Number of unread unmuted peers in folder
UnreadUnmutedPeersCount int
// Number of unread messages from muted peers in folder
UnreadMutedMessagesCount int
// Number of unread messages from unmuted peers in folder
UnreadUnmutedMessagesCount int
}
// DialogFolderTypeID is TL type id of DialogFolder.
const DialogFolderTypeID = 0x71bd134c
// construct implements constructor of DialogClass.
func (d DialogFolder) construct() DialogClass { return &d }
// Ensuring interfaces in compile-time for DialogFolder.
var (
_ bin.Encoder = &DialogFolder{}
_ bin.Decoder = &DialogFolder{}
_ bin.BareEncoder = &DialogFolder{}
_ bin.BareDecoder = &DialogFolder{}
_ DialogClass = &DialogFolder{}
)
func (d *DialogFolder) Zero() bool {
if d == nil {
return true
}
if !(d.Flags.Zero()) {
return false
}
if !(d.Pinned == false) {
return false
}
if !(d.Folder.Zero()) {
return false
}
if !(d.Peer == nil) {
return false
}
if !(d.TopMessage == 0) {
return false
}
if !(d.UnreadMutedPeersCount == 0) {
return false
}
if !(d.UnreadUnmutedPeersCount == 0) {
return false
}
if !(d.UnreadMutedMessagesCount == 0) {
return false
}
if !(d.UnreadUnmutedMessagesCount == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (d *DialogFolder) String() string {
if d == nil {
return "DialogFolder(nil)"
}
type Alias DialogFolder
return fmt.Sprintf("DialogFolder%+v", Alias(*d))
}
// FillFrom fills DialogFolder from given interface.
func (d *DialogFolder) FillFrom(from interface {
GetPinned() (value bool)
GetFolder() (value Folder)
GetPeer() (value PeerClass)
GetTopMessage() (value int)
GetUnreadMutedPeersCount() (value int)
GetUnreadUnmutedPeersCount() (value int)
GetUnreadMutedMessagesCount() (value int)
GetUnreadUnmutedMessagesCount() (value int)
}) {
d.Pinned = from.GetPinned()
d.Folder = from.GetFolder()
d.Peer = from.GetPeer()
d.TopMessage = from.GetTopMessage()
d.UnreadMutedPeersCount = from.GetUnreadMutedPeersCount()
d.UnreadUnmutedPeersCount = from.GetUnreadUnmutedPeersCount()
d.UnreadMutedMessagesCount = from.GetUnreadMutedMessagesCount()
d.UnreadUnmutedMessagesCount = from.GetUnreadUnmutedMessagesCount()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DialogFolder) TypeID() uint32 {
return DialogFolderTypeID
}
// TypeName returns name of type in TL schema.
func (*DialogFolder) TypeName() string {
return "dialogFolder"
}
// TypeInfo returns info about TL type.
func (d *DialogFolder) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "dialogFolder",
ID: DialogFolderTypeID,
}
if d == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Pinned",
SchemaName: "pinned",
Null: !d.Flags.Has(2),
},
{
Name: "Folder",
SchemaName: "folder",
},
{
Name: "Peer",
SchemaName: "peer",
},
{
Name: "TopMessage",
SchemaName: "top_message",
},
{
Name: "UnreadMutedPeersCount",
SchemaName: "unread_muted_peers_count",
},
{
Name: "UnreadUnmutedPeersCount",
SchemaName: "unread_unmuted_peers_count",
},
{
Name: "UnreadMutedMessagesCount",
SchemaName: "unread_muted_messages_count",
},
{
Name: "UnreadUnmutedMessagesCount",
SchemaName: "unread_unmuted_messages_count",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (d *DialogFolder) SetFlags() {
if !(d.Pinned == false) {
d.Flags.Set(2)
}
}
// Encode implements bin.Encoder.
func (d *DialogFolder) Encode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode dialogFolder#71bd134c as nil")
}
b.PutID(DialogFolderTypeID)
return d.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (d *DialogFolder) EncodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't encode dialogFolder#71bd134c as nil")
}
d.SetFlags()
if err := d.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialogFolder#71bd134c: field flags: %w", err)
}
if err := d.Folder.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialogFolder#71bd134c: field folder: %w", err)
}
if d.Peer == nil {
return fmt.Errorf("unable to encode dialogFolder#71bd134c: field peer is nil")
}
if err := d.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode dialogFolder#71bd134c: field peer: %w", err)
}
b.PutInt(d.TopMessage)
b.PutInt(d.UnreadMutedPeersCount)
b.PutInt(d.UnreadUnmutedPeersCount)
b.PutInt(d.UnreadMutedMessagesCount)
b.PutInt(d.UnreadUnmutedMessagesCount)
return nil
}
// Decode implements bin.Decoder.
func (d *DialogFolder) Decode(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode dialogFolder#71bd134c to nil")
}
if err := b.ConsumeID(DialogFolderTypeID); err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: %w", err)
}
return d.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (d *DialogFolder) DecodeBare(b *bin.Buffer) error {
if d == nil {
return fmt.Errorf("can't decode dialogFolder#71bd134c to nil")
}
{
if err := d.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field flags: %w", err)
}
}
d.Pinned = d.Flags.Has(2)
{
if err := d.Folder.Decode(b); err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field folder: %w", err)
}
}
{
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field peer: %w", err)
}
d.Peer = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field top_message: %w", err)
}
d.TopMessage = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_muted_peers_count: %w", err)
}
d.UnreadMutedPeersCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_unmuted_peers_count: %w", err)
}
d.UnreadUnmutedPeersCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_muted_messages_count: %w", err)
}
d.UnreadMutedMessagesCount = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_unmuted_messages_count: %w", err)
}
d.UnreadUnmutedMessagesCount = value
}
return nil
}
// SetPinned sets value of Pinned conditional field.
func (d *DialogFolder) SetPinned(value bool) {
if value {
d.Flags.Set(2)
d.Pinned = true
} else {
d.Flags.Unset(2)
d.Pinned = false
}
}
// GetPinned returns value of Pinned conditional field.