-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
tl_bot_inline_result_gen.go
1031 lines (947 loc) · 24 KB
/
tl_bot_inline_result_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{}
)
// BotInlineResult represents TL type `botInlineResult#11965f3a`.
// Generic result
//
// See https://core.telegram.org/constructor/botInlineResult for reference.
type BotInlineResult struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Result ID
ID string
// Result type (see bot API docs¹)
//
// Links:
// 1) https://core.telegram.org/bots/api#inlinequeryresult
Type string
// Result title
//
// Use SetTitle and GetTitle helpers.
Title string
// Result description
//
// Use SetDescription and GetDescription helpers.
Description string
// URL of article or webpage
//
// Use SetURL and GetURL helpers.
URL string
// Thumbnail for the result
//
// Use SetThumb and GetThumb helpers.
Thumb WebDocumentClass
// Content of the result
//
// Use SetContent and GetContent helpers.
Content WebDocumentClass
// Message to send
SendMessage BotInlineMessageClass
}
// BotInlineResultTypeID is TL type id of BotInlineResult.
const BotInlineResultTypeID = 0x11965f3a
// construct implements constructor of BotInlineResultClass.
func (b BotInlineResult) construct() BotInlineResultClass { return &b }
// Ensuring interfaces in compile-time for BotInlineResult.
var (
_ bin.Encoder = &BotInlineResult{}
_ bin.Decoder = &BotInlineResult{}
_ bin.BareEncoder = &BotInlineResult{}
_ bin.BareDecoder = &BotInlineResult{}
_ BotInlineResultClass = &BotInlineResult{}
)
func (b *BotInlineResult) Zero() bool {
if b == nil {
return true
}
if !(b.Flags.Zero()) {
return false
}
if !(b.ID == "") {
return false
}
if !(b.Type == "") {
return false
}
if !(b.Title == "") {
return false
}
if !(b.Description == "") {
return false
}
if !(b.URL == "") {
return false
}
if !(b.Thumb == nil) {
return false
}
if !(b.Content == nil) {
return false
}
if !(b.SendMessage == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *BotInlineResult) String() string {
if b == nil {
return "BotInlineResult(nil)"
}
type Alias BotInlineResult
return fmt.Sprintf("BotInlineResult%+v", Alias(*b))
}
// FillFrom fills BotInlineResult from given interface.
func (b *BotInlineResult) FillFrom(from interface {
GetID() (value string)
GetType() (value string)
GetTitle() (value string, ok bool)
GetDescription() (value string, ok bool)
GetURL() (value string, ok bool)
GetThumb() (value WebDocumentClass, ok bool)
GetContent() (value WebDocumentClass, ok bool)
GetSendMessage() (value BotInlineMessageClass)
}) {
b.ID = from.GetID()
b.Type = from.GetType()
if val, ok := from.GetTitle(); ok {
b.Title = val
}
if val, ok := from.GetDescription(); ok {
b.Description = val
}
if val, ok := from.GetURL(); ok {
b.URL = val
}
if val, ok := from.GetThumb(); ok {
b.Thumb = val
}
if val, ok := from.GetContent(); ok {
b.Content = val
}
b.SendMessage = from.GetSendMessage()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BotInlineResult) TypeID() uint32 {
return BotInlineResultTypeID
}
// TypeName returns name of type in TL schema.
func (*BotInlineResult) TypeName() string {
return "botInlineResult"
}
// TypeInfo returns info about TL type.
func (b *BotInlineResult) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "botInlineResult",
ID: BotInlineResultTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Type",
SchemaName: "type",
},
{
Name: "Title",
SchemaName: "title",
Null: !b.Flags.Has(1),
},
{
Name: "Description",
SchemaName: "description",
Null: !b.Flags.Has(2),
},
{
Name: "URL",
SchemaName: "url",
Null: !b.Flags.Has(3),
},
{
Name: "Thumb",
SchemaName: "thumb",
Null: !b.Flags.Has(4),
},
{
Name: "Content",
SchemaName: "content",
Null: !b.Flags.Has(5),
},
{
Name: "SendMessage",
SchemaName: "send_message",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (b *BotInlineResult) SetFlags() {
if !(b.Title == "") {
b.Flags.Set(1)
}
if !(b.Description == "") {
b.Flags.Set(2)
}
if !(b.URL == "") {
b.Flags.Set(3)
}
if !(b.Thumb == nil) {
b.Flags.Set(4)
}
if !(b.Content == nil) {
b.Flags.Set(5)
}
}
// Encode implements bin.Encoder.
func (b *BotInlineResult) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode botInlineResult#11965f3a as nil")
}
buf.PutID(BotInlineResultTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BotInlineResult) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode botInlineResult#11965f3a as nil")
}
b.SetFlags()
if err := b.Flags.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field flags: %w", err)
}
buf.PutString(b.ID)
buf.PutString(b.Type)
if b.Flags.Has(1) {
buf.PutString(b.Title)
}
if b.Flags.Has(2) {
buf.PutString(b.Description)
}
if b.Flags.Has(3) {
buf.PutString(b.URL)
}
if b.Flags.Has(4) {
if b.Thumb == nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field thumb is nil")
}
if err := b.Thumb.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field thumb: %w", err)
}
}
if b.Flags.Has(5) {
if b.Content == nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field content is nil")
}
if err := b.Content.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field content: %w", err)
}
}
if b.SendMessage == nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field send_message is nil")
}
if err := b.SendMessage.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineResult#11965f3a: field send_message: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (b *BotInlineResult) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode botInlineResult#11965f3a to nil")
}
if err := buf.ConsumeID(BotInlineResultTypeID); err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BotInlineResult) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode botInlineResult#11965f3a to nil")
}
{
if err := b.Flags.Decode(buf); err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field flags: %w", err)
}
}
{
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field id: %w", err)
}
b.ID = value
}
{
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field type: %w", err)
}
b.Type = value
}
if b.Flags.Has(1) {
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field title: %w", err)
}
b.Title = value
}
if b.Flags.Has(2) {
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field description: %w", err)
}
b.Description = value
}
if b.Flags.Has(3) {
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field url: %w", err)
}
b.URL = value
}
if b.Flags.Has(4) {
value, err := DecodeWebDocument(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field thumb: %w", err)
}
b.Thumb = value
}
if b.Flags.Has(5) {
value, err := DecodeWebDocument(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field content: %w", err)
}
b.Content = value
}
{
value, err := DecodeBotInlineMessage(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineResult#11965f3a: field send_message: %w", err)
}
b.SendMessage = value
}
return nil
}
// GetID returns value of ID field.
func (b *BotInlineResult) GetID() (value string) {
if b == nil {
return
}
return b.ID
}
// GetType returns value of Type field.
func (b *BotInlineResult) GetType() (value string) {
if b == nil {
return
}
return b.Type
}
// SetTitle sets value of Title conditional field.
func (b *BotInlineResult) SetTitle(value string) {
b.Flags.Set(1)
b.Title = value
}
// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func (b *BotInlineResult) GetTitle() (value string, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(1) {
return value, false
}
return b.Title, true
}
// SetDescription sets value of Description conditional field.
func (b *BotInlineResult) SetDescription(value string) {
b.Flags.Set(2)
b.Description = value
}
// GetDescription returns value of Description conditional field and
// boolean which is true if field was set.
func (b *BotInlineResult) GetDescription() (value string, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(2) {
return value, false
}
return b.Description, true
}
// SetURL sets value of URL conditional field.
func (b *BotInlineResult) SetURL(value string) {
b.Flags.Set(3)
b.URL = value
}
// GetURL returns value of URL conditional field and
// boolean which is true if field was set.
func (b *BotInlineResult) GetURL() (value string, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(3) {
return value, false
}
return b.URL, true
}
// SetThumb sets value of Thumb conditional field.
func (b *BotInlineResult) SetThumb(value WebDocumentClass) {
b.Flags.Set(4)
b.Thumb = value
}
// GetThumb returns value of Thumb conditional field and
// boolean which is true if field was set.
func (b *BotInlineResult) GetThumb() (value WebDocumentClass, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(4) {
return value, false
}
return b.Thumb, true
}
// SetContent sets value of Content conditional field.
func (b *BotInlineResult) SetContent(value WebDocumentClass) {
b.Flags.Set(5)
b.Content = value
}
// GetContent returns value of Content conditional field and
// boolean which is true if field was set.
func (b *BotInlineResult) GetContent() (value WebDocumentClass, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(5) {
return value, false
}
return b.Content, true
}
// GetSendMessage returns value of SendMessage field.
func (b *BotInlineResult) GetSendMessage() (value BotInlineMessageClass) {
if b == nil {
return
}
return b.SendMessage
}
// BotInlineMediaResult represents TL type `botInlineMediaResult#17db940b`.
// Media result
//
// See https://core.telegram.org/constructor/botInlineMediaResult for reference.
type BotInlineMediaResult struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Result ID
ID string
// Result type (see bot API docs¹)
//
// Links:
// 1) https://core.telegram.org/bots/api#inlinequeryresult
Type string
// If type is photo, the photo to send
//
// Use SetPhoto and GetPhoto helpers.
Photo PhotoClass
// If type is document, the document to send
//
// Use SetDocument and GetDocument helpers.
Document DocumentClass
// Result title
//
// Use SetTitle and GetTitle helpers.
Title string
// Description
//
// Use SetDescription and GetDescription helpers.
Description string
// Depending on the type and on the constructor¹, contains the caption of the media or
// the content of the message to be sent instead of the media
//
// Links:
// 1) https://core.telegram.org/type/BotInlineMessage
SendMessage BotInlineMessageClass
}
// BotInlineMediaResultTypeID is TL type id of BotInlineMediaResult.
const BotInlineMediaResultTypeID = 0x17db940b
// construct implements constructor of BotInlineResultClass.
func (b BotInlineMediaResult) construct() BotInlineResultClass { return &b }
// Ensuring interfaces in compile-time for BotInlineMediaResult.
var (
_ bin.Encoder = &BotInlineMediaResult{}
_ bin.Decoder = &BotInlineMediaResult{}
_ bin.BareEncoder = &BotInlineMediaResult{}
_ bin.BareDecoder = &BotInlineMediaResult{}
_ BotInlineResultClass = &BotInlineMediaResult{}
)
func (b *BotInlineMediaResult) Zero() bool {
if b == nil {
return true
}
if !(b.Flags.Zero()) {
return false
}
if !(b.ID == "") {
return false
}
if !(b.Type == "") {
return false
}
if !(b.Photo == nil) {
return false
}
if !(b.Document == nil) {
return false
}
if !(b.Title == "") {
return false
}
if !(b.Description == "") {
return false
}
if !(b.SendMessage == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *BotInlineMediaResult) String() string {
if b == nil {
return "BotInlineMediaResult(nil)"
}
type Alias BotInlineMediaResult
return fmt.Sprintf("BotInlineMediaResult%+v", Alias(*b))
}
// FillFrom fills BotInlineMediaResult from given interface.
func (b *BotInlineMediaResult) FillFrom(from interface {
GetID() (value string)
GetType() (value string)
GetPhoto() (value PhotoClass, ok bool)
GetDocument() (value DocumentClass, ok bool)
GetTitle() (value string, ok bool)
GetDescription() (value string, ok bool)
GetSendMessage() (value BotInlineMessageClass)
}) {
b.ID = from.GetID()
b.Type = from.GetType()
if val, ok := from.GetPhoto(); ok {
b.Photo = val
}
if val, ok := from.GetDocument(); ok {
b.Document = val
}
if val, ok := from.GetTitle(); ok {
b.Title = val
}
if val, ok := from.GetDescription(); ok {
b.Description = val
}
b.SendMessage = from.GetSendMessage()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BotInlineMediaResult) TypeID() uint32 {
return BotInlineMediaResultTypeID
}
// TypeName returns name of type in TL schema.
func (*BotInlineMediaResult) TypeName() string {
return "botInlineMediaResult"
}
// TypeInfo returns info about TL type.
func (b *BotInlineMediaResult) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "botInlineMediaResult",
ID: BotInlineMediaResultTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Type",
SchemaName: "type",
},
{
Name: "Photo",
SchemaName: "photo",
Null: !b.Flags.Has(0),
},
{
Name: "Document",
SchemaName: "document",
Null: !b.Flags.Has(1),
},
{
Name: "Title",
SchemaName: "title",
Null: !b.Flags.Has(2),
},
{
Name: "Description",
SchemaName: "description",
Null: !b.Flags.Has(3),
},
{
Name: "SendMessage",
SchemaName: "send_message",
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (b *BotInlineMediaResult) SetFlags() {
if !(b.Photo == nil) {
b.Flags.Set(0)
}
if !(b.Document == nil) {
b.Flags.Set(1)
}
if !(b.Title == "") {
b.Flags.Set(2)
}
if !(b.Description == "") {
b.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (b *BotInlineMediaResult) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode botInlineMediaResult#17db940b as nil")
}
buf.PutID(BotInlineMediaResultTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *BotInlineMediaResult) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode botInlineMediaResult#17db940b as nil")
}
b.SetFlags()
if err := b.Flags.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field flags: %w", err)
}
buf.PutString(b.ID)
buf.PutString(b.Type)
if b.Flags.Has(0) {
if b.Photo == nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field photo is nil")
}
if err := b.Photo.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field photo: %w", err)
}
}
if b.Flags.Has(1) {
if b.Document == nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field document is nil")
}
if err := b.Document.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field document: %w", err)
}
}
if b.Flags.Has(2) {
buf.PutString(b.Title)
}
if b.Flags.Has(3) {
buf.PutString(b.Description)
}
if b.SendMessage == nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field send_message is nil")
}
if err := b.SendMessage.Encode(buf); err != nil {
return fmt.Errorf("unable to encode botInlineMediaResult#17db940b: field send_message: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (b *BotInlineMediaResult) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode botInlineMediaResult#17db940b to nil")
}
if err := buf.ConsumeID(BotInlineMediaResultTypeID); err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *BotInlineMediaResult) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode botInlineMediaResult#17db940b to nil")
}
{
if err := b.Flags.Decode(buf); err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field flags: %w", err)
}
}
{
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field id: %w", err)
}
b.ID = value
}
{
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field type: %w", err)
}
b.Type = value
}
if b.Flags.Has(0) {
value, err := DecodePhoto(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field photo: %w", err)
}
b.Photo = value
}
if b.Flags.Has(1) {
value, err := DecodeDocument(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field document: %w", err)
}
b.Document = value
}
if b.Flags.Has(2) {
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field title: %w", err)
}
b.Title = value
}
if b.Flags.Has(3) {
value, err := buf.String()
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field description: %w", err)
}
b.Description = value
}
{
value, err := DecodeBotInlineMessage(buf)
if err != nil {
return fmt.Errorf("unable to decode botInlineMediaResult#17db940b: field send_message: %w", err)
}
b.SendMessage = value
}
return nil
}
// GetID returns value of ID field.
func (b *BotInlineMediaResult) GetID() (value string) {
if b == nil {
return
}
return b.ID
}
// GetType returns value of Type field.
func (b *BotInlineMediaResult) GetType() (value string) {
if b == nil {
return
}
return b.Type
}
// SetPhoto sets value of Photo conditional field.
func (b *BotInlineMediaResult) SetPhoto(value PhotoClass) {
b.Flags.Set(0)
b.Photo = value
}
// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func (b *BotInlineMediaResult) GetPhoto() (value PhotoClass, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(0) {
return value, false
}
return b.Photo, true
}
// SetDocument sets value of Document conditional field.
func (b *BotInlineMediaResult) SetDocument(value DocumentClass) {
b.Flags.Set(1)
b.Document = value
}
// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func (b *BotInlineMediaResult) GetDocument() (value DocumentClass, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(1) {
return value, false
}
return b.Document, true
}
// SetTitle sets value of Title conditional field.
func (b *BotInlineMediaResult) SetTitle(value string) {
b.Flags.Set(2)
b.Title = value
}
// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func (b *BotInlineMediaResult) GetTitle() (value string, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(2) {
return value, false
}
return b.Title, true
}
// SetDescription sets value of Description conditional field.
func (b *BotInlineMediaResult) SetDescription(value string) {
b.Flags.Set(3)
b.Description = value
}
// GetDescription returns value of Description conditional field and
// boolean which is true if field was set.
func (b *BotInlineMediaResult) GetDescription() (value string, ok bool) {
if b == nil {
return
}
if !b.Flags.Has(3) {
return value, false
}
return b.Description, true
}
// GetSendMessage returns value of SendMessage field.
func (b *BotInlineMediaResult) GetSendMessage() (value BotInlineMessageClass) {
if b == nil {
return
}
return b.SendMessage
}
// BotInlineResultClassName is schema name of BotInlineResultClass.
const BotInlineResultClassName = "BotInlineResult"
// BotInlineResultClass represents BotInlineResult generic type.
//
// See https://core.telegram.org/type/BotInlineResult for reference.
//
// Example:
//
// g, err := tg.DecodeBotInlineResult(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.BotInlineResult: // botInlineResult#11965f3a
// case *tg.BotInlineMediaResult: // botInlineMediaResult#17db940b
// default: panic(v)
// }
type BotInlineResultClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() BotInlineResultClass
// 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
// Result ID
GetID() (value string)
// Result type (see bot API docs¹)
//
// Links:
// 1) https://core.telegram.org/bots/api#inlinequeryresult
GetType() (value string)
// Result title
GetTitle() (value string, ok bool)
// Result description
GetDescription() (value string, ok bool)
// Message to send
GetSendMessage() (value BotInlineMessageClass)
}
// DecodeBotInlineResult implements binary de-serialization for BotInlineResultClass.
func DecodeBotInlineResult(buf *bin.Buffer) (BotInlineResultClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case BotInlineResultTypeID:
// Decoding botInlineResult#11965f3a.
v := BotInlineResult{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode BotInlineResultClass: %w", err)
}
return &v, nil
case BotInlineMediaResultTypeID:
// Decoding botInlineMediaResult#17db940b.
v := BotInlineMediaResult{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode BotInlineResultClass: %w", err)
}