-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
tl_notify_peer_gen.go
583 lines (509 loc) · 13.7 KB
/
tl_notify_peer_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
// 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{}
)
// NotifyPeer represents TL type `notifyPeer#9fd40bd8`.
// Notifications generated by a certain user or group.
//
// See https://core.telegram.org/constructor/notifyPeer for reference.
type NotifyPeer struct {
// user or group
Peer PeerClass
}
// NotifyPeerTypeID is TL type id of NotifyPeer.
const NotifyPeerTypeID = 0x9fd40bd8
// construct implements constructor of NotifyPeerClass.
func (n NotifyPeer) construct() NotifyPeerClass { return &n }
// Ensuring interfaces in compile-time for NotifyPeer.
var (
_ bin.Encoder = &NotifyPeer{}
_ bin.Decoder = &NotifyPeer{}
_ bin.BareEncoder = &NotifyPeer{}
_ bin.BareDecoder = &NotifyPeer{}
_ NotifyPeerClass = &NotifyPeer{}
)
func (n *NotifyPeer) Zero() bool {
if n == nil {
return true
}
if !(n.Peer == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (n *NotifyPeer) String() string {
if n == nil {
return "NotifyPeer(nil)"
}
type Alias NotifyPeer
return fmt.Sprintf("NotifyPeer%+v", Alias(*n))
}
// FillFrom fills NotifyPeer from given interface.
func (n *NotifyPeer) FillFrom(from interface {
GetPeer() (value PeerClass)
}) {
n.Peer = from.GetPeer()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*NotifyPeer) TypeID() uint32 {
return NotifyPeerTypeID
}
// TypeName returns name of type in TL schema.
func (*NotifyPeer) TypeName() string {
return "notifyPeer"
}
// TypeInfo returns info about TL type.
func (n *NotifyPeer) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "notifyPeer",
ID: NotifyPeerTypeID,
}
if n == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Peer",
SchemaName: "peer",
},
}
return typ
}
// Encode implements bin.Encoder.
func (n *NotifyPeer) Encode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyPeer#9fd40bd8 as nil")
}
b.PutID(NotifyPeerTypeID)
return n.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (n *NotifyPeer) EncodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyPeer#9fd40bd8 as nil")
}
if n.Peer == nil {
return fmt.Errorf("unable to encode notifyPeer#9fd40bd8: field peer is nil")
}
if err := n.Peer.Encode(b); err != nil {
return fmt.Errorf("unable to encode notifyPeer#9fd40bd8: field peer: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (n *NotifyPeer) Decode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyPeer#9fd40bd8 to nil")
}
if err := b.ConsumeID(NotifyPeerTypeID); err != nil {
return fmt.Errorf("unable to decode notifyPeer#9fd40bd8: %w", err)
}
return n.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (n *NotifyPeer) DecodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyPeer#9fd40bd8 to nil")
}
{
value, err := DecodePeer(b)
if err != nil {
return fmt.Errorf("unable to decode notifyPeer#9fd40bd8: field peer: %w", err)
}
n.Peer = value
}
return nil
}
// GetPeer returns value of Peer field.
func (n *NotifyPeer) GetPeer() (value PeerClass) {
if n == nil {
return
}
return n.Peer
}
// NotifyUsers represents TL type `notifyUsers#b4c83b4c`.
// Notifications generated by all users.
//
// See https://core.telegram.org/constructor/notifyUsers for reference.
type NotifyUsers struct {
}
// NotifyUsersTypeID is TL type id of NotifyUsers.
const NotifyUsersTypeID = 0xb4c83b4c
// construct implements constructor of NotifyPeerClass.
func (n NotifyUsers) construct() NotifyPeerClass { return &n }
// Ensuring interfaces in compile-time for NotifyUsers.
var (
_ bin.Encoder = &NotifyUsers{}
_ bin.Decoder = &NotifyUsers{}
_ bin.BareEncoder = &NotifyUsers{}
_ bin.BareDecoder = &NotifyUsers{}
_ NotifyPeerClass = &NotifyUsers{}
)
func (n *NotifyUsers) Zero() bool {
if n == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (n *NotifyUsers) String() string {
if n == nil {
return "NotifyUsers(nil)"
}
type Alias NotifyUsers
return fmt.Sprintf("NotifyUsers%+v", Alias(*n))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*NotifyUsers) TypeID() uint32 {
return NotifyUsersTypeID
}
// TypeName returns name of type in TL schema.
func (*NotifyUsers) TypeName() string {
return "notifyUsers"
}
// TypeInfo returns info about TL type.
func (n *NotifyUsers) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "notifyUsers",
ID: NotifyUsersTypeID,
}
if n == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (n *NotifyUsers) Encode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyUsers#b4c83b4c as nil")
}
b.PutID(NotifyUsersTypeID)
return n.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (n *NotifyUsers) EncodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyUsers#b4c83b4c as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (n *NotifyUsers) Decode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyUsers#b4c83b4c to nil")
}
if err := b.ConsumeID(NotifyUsersTypeID); err != nil {
return fmt.Errorf("unable to decode notifyUsers#b4c83b4c: %w", err)
}
return n.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (n *NotifyUsers) DecodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyUsers#b4c83b4c to nil")
}
return nil
}
// NotifyChats represents TL type `notifyChats#c007cec3`.
// Notifications generated by all groups.
//
// See https://core.telegram.org/constructor/notifyChats for reference.
type NotifyChats struct {
}
// NotifyChatsTypeID is TL type id of NotifyChats.
const NotifyChatsTypeID = 0xc007cec3
// construct implements constructor of NotifyPeerClass.
func (n NotifyChats) construct() NotifyPeerClass { return &n }
// Ensuring interfaces in compile-time for NotifyChats.
var (
_ bin.Encoder = &NotifyChats{}
_ bin.Decoder = &NotifyChats{}
_ bin.BareEncoder = &NotifyChats{}
_ bin.BareDecoder = &NotifyChats{}
_ NotifyPeerClass = &NotifyChats{}
)
func (n *NotifyChats) Zero() bool {
if n == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (n *NotifyChats) String() string {
if n == nil {
return "NotifyChats(nil)"
}
type Alias NotifyChats
return fmt.Sprintf("NotifyChats%+v", Alias(*n))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*NotifyChats) TypeID() uint32 {
return NotifyChatsTypeID
}
// TypeName returns name of type in TL schema.
func (*NotifyChats) TypeName() string {
return "notifyChats"
}
// TypeInfo returns info about TL type.
func (n *NotifyChats) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "notifyChats",
ID: NotifyChatsTypeID,
}
if n == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (n *NotifyChats) Encode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyChats#c007cec3 as nil")
}
b.PutID(NotifyChatsTypeID)
return n.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (n *NotifyChats) EncodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyChats#c007cec3 as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (n *NotifyChats) Decode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyChats#c007cec3 to nil")
}
if err := b.ConsumeID(NotifyChatsTypeID); err != nil {
return fmt.Errorf("unable to decode notifyChats#c007cec3: %w", err)
}
return n.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (n *NotifyChats) DecodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyChats#c007cec3 to nil")
}
return nil
}
// NotifyBroadcasts represents TL type `notifyBroadcasts#d612e8ef`.
// Channel notification settings
//
// See https://core.telegram.org/constructor/notifyBroadcasts for reference.
type NotifyBroadcasts struct {
}
// NotifyBroadcastsTypeID is TL type id of NotifyBroadcasts.
const NotifyBroadcastsTypeID = 0xd612e8ef
// construct implements constructor of NotifyPeerClass.
func (n NotifyBroadcasts) construct() NotifyPeerClass { return &n }
// Ensuring interfaces in compile-time for NotifyBroadcasts.
var (
_ bin.Encoder = &NotifyBroadcasts{}
_ bin.Decoder = &NotifyBroadcasts{}
_ bin.BareEncoder = &NotifyBroadcasts{}
_ bin.BareDecoder = &NotifyBroadcasts{}
_ NotifyPeerClass = &NotifyBroadcasts{}
)
func (n *NotifyBroadcasts) Zero() bool {
if n == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (n *NotifyBroadcasts) String() string {
if n == nil {
return "NotifyBroadcasts(nil)"
}
type Alias NotifyBroadcasts
return fmt.Sprintf("NotifyBroadcasts%+v", Alias(*n))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*NotifyBroadcasts) TypeID() uint32 {
return NotifyBroadcastsTypeID
}
// TypeName returns name of type in TL schema.
func (*NotifyBroadcasts) TypeName() string {
return "notifyBroadcasts"
}
// TypeInfo returns info about TL type.
func (n *NotifyBroadcasts) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "notifyBroadcasts",
ID: NotifyBroadcastsTypeID,
}
if n == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (n *NotifyBroadcasts) Encode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyBroadcasts#d612e8ef as nil")
}
b.PutID(NotifyBroadcastsTypeID)
return n.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (n *NotifyBroadcasts) EncodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode notifyBroadcasts#d612e8ef as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (n *NotifyBroadcasts) Decode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyBroadcasts#d612e8ef to nil")
}
if err := b.ConsumeID(NotifyBroadcastsTypeID); err != nil {
return fmt.Errorf("unable to decode notifyBroadcasts#d612e8ef: %w", err)
}
return n.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (n *NotifyBroadcasts) DecodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode notifyBroadcasts#d612e8ef to nil")
}
return nil
}
// NotifyPeerClassName is schema name of NotifyPeerClass.
const NotifyPeerClassName = "NotifyPeer"
// NotifyPeerClass represents NotifyPeer generic type.
//
// See https://core.telegram.org/type/NotifyPeer for reference.
//
// Example:
//
// g, err := tg.DecodeNotifyPeer(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.NotifyPeer: // notifyPeer#9fd40bd8
// case *tg.NotifyUsers: // notifyUsers#b4c83b4c
// case *tg.NotifyChats: // notifyChats#c007cec3
// case *tg.NotifyBroadcasts: // notifyBroadcasts#d612e8ef
// default: panic(v)
// }
type NotifyPeerClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() NotifyPeerClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
}
// DecodeNotifyPeer implements binary de-serialization for NotifyPeerClass.
func DecodeNotifyPeer(buf *bin.Buffer) (NotifyPeerClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case NotifyPeerTypeID:
// Decoding notifyPeer#9fd40bd8.
v := NotifyPeer{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err)
}
return &v, nil
case NotifyUsersTypeID:
// Decoding notifyUsers#b4c83b4c.
v := NotifyUsers{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err)
}
return &v, nil
case NotifyChatsTypeID:
// Decoding notifyChats#c007cec3.
v := NotifyChats{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err)
}
return &v, nil
case NotifyBroadcastsTypeID:
// Decoding notifyBroadcasts#d612e8ef.
v := NotifyBroadcasts{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", bin.NewUnexpectedID(id))
}
}
// NotifyPeer boxes the NotifyPeerClass providing a helper.
type NotifyPeerBox struct {
NotifyPeer NotifyPeerClass
}
// Decode implements bin.Decoder for NotifyPeerBox.
func (b *NotifyPeerBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode NotifyPeerBox to nil")
}
v, err := DecodeNotifyPeer(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.NotifyPeer = v
return nil
}
// Encode implements bin.Encode for NotifyPeerBox.
func (b *NotifyPeerBox) Encode(buf *bin.Buffer) error {
if b == nil || b.NotifyPeer == nil {
return fmt.Errorf("unable to encode NotifyPeerClass as nil")
}
return b.NotifyPeer.Encode(buf)
}