forked from PaulSonOfLars/gotgbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_types.go
More file actions
executable file
·9083 lines (8208 loc) · 403 KB
/
gen_types.go
File metadata and controls
executable file
·9083 lines (8208 loc) · 403 KB
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
// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
// Regen by running 'go generate' in the repo root.
package gotgbot
import (
"encoding/json"
"fmt"
)
type ReplyMarkup interface {
// replyMarkup exists to avoid external types implementing this interface.
replyMarkup()
}
// Ensure that all subtypes correctly implement the parent interface.
var (
_ ReplyMarkup = ForceReply{}
_ ReplyMarkup = InlineKeyboardMarkup{}
_ ReplyMarkup = ReplyKeyboardMarkup{}
_ ReplyMarkup = ReplyKeyboardRemove{}
)
// Animation (https://core.telegram.org/bots/api#animation)
//
// This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
type Animation struct {
// Identifier for this file, which can be used to download or reuse the file
FileId string `json:"file_id"`
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
FileUniqueId string `json:"file_unique_id"`
// Video width as defined by the sender
Width int64 `json:"width"`
// Video height as defined by the sender
Height int64 `json:"height"`
// Duration of the video in seconds as defined by the sender
Duration int64 `json:"duration"`
// Optional. Animation thumbnail as defined by the sender
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
// Optional. Original animation filename as defined by the sender
FileName string `json:"file_name,omitempty"`
// Optional. MIME type of the file as defined by the sender
MimeType string `json:"mime_type,omitempty"`
// Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
FileSize int64 `json:"file_size,omitempty"`
}
// Audio (https://core.telegram.org/bots/api#audio)
//
// This object represents an audio file to be treated as music by the Telegram clients.
type Audio struct {
// Identifier for this file, which can be used to download or reuse the file
FileId string `json:"file_id"`
// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
FileUniqueId string `json:"file_unique_id"`
// Duration of the audio in seconds as defined by the sender
Duration int64 `json:"duration"`
// Optional. Performer of the audio as defined by the sender or by audio tags
Performer string `json:"performer,omitempty"`
// Optional. Title of the audio as defined by the sender or by audio tags
Title string `json:"title,omitempty"`
// Optional. Original filename as defined by the sender
FileName string `json:"file_name,omitempty"`
// Optional. MIME type of the file as defined by the sender
MimeType string `json:"mime_type,omitempty"`
// Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
FileSize int64 `json:"file_size,omitempty"`
// Optional. Thumbnail of the album cover to which the music file belongs
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
}
// BackgroundFill (https://core.telegram.org/bots/api#backgroundfill)
//
// This object describes the way a background is filled based on the selected colors. Currently, it can be one of
// - BackgroundFillSolid
// - BackgroundFillGradient
// - BackgroundFillFreeformGradient
type BackgroundFill interface {
GetType() string
// MergeBackgroundFill returns a MergedBackgroundFill struct to simplify working with complex telegram types in a non-generic world.
MergeBackgroundFill() MergedBackgroundFill
// backgroundFill exists to avoid external types implementing this interface.
backgroundFill()
}
// Ensure that all subtypes correctly implement the parent interface.
var (
_ BackgroundFill = BackgroundFillSolid{}
_ BackgroundFill = BackgroundFillGradient{}
_ BackgroundFill = BackgroundFillFreeformGradient{}
)
// MergedBackgroundFill is a helper type to simplify interactions with the various BackgroundFill subtypes.
type MergedBackgroundFill struct {
// Type of the background fill
Type string `json:"type"`
// Optional. The color of the background fill in the RGB24 format (Only for solid)
Color int64 `json:"color,omitempty"`
// Optional. Top color of the gradient in the RGB24 format (Only for gradient)
TopColor int64 `json:"top_color,omitempty"`
// Optional. Bottom color of the gradient in the RGB24 format (Only for gradient)
BottomColor int64 `json:"bottom_color,omitempty"`
// Optional. Clockwise rotation angle of the background fill in degrees; 0-359 (Only for gradient)
RotationAngle int64 `json:"rotation_angle,omitempty"`
// Optional. A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format (Only for freeform_gradient)
Colors []int64 `json:"colors,omitempty"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v MergedBackgroundFill) GetType() string {
return v.Type
}
// MergedBackgroundFill.backgroundFill is a dummy method to avoid interface implementation.
func (v MergedBackgroundFill) backgroundFill() {}
// MergeBackgroundFill returns a MergedBackgroundFill struct to simplify working with types in a non-generic world.
func (v MergedBackgroundFill) MergeBackgroundFill() MergedBackgroundFill {
return v
}
// unmarshalBackgroundFillArray is a JSON unmarshalling helper which allows unmarshalling an array of interfaces
// using unmarshalBackgroundFill.
func unmarshalBackgroundFillArray(d json.RawMessage) ([]BackgroundFill, error) {
if len(d) == 0 {
return nil, nil
}
var ds []json.RawMessage
err := json.Unmarshal(d, &ds)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal initial BackgroundFill JSON into an array: %w", err)
}
var vs []BackgroundFill
for idx, d := range ds {
v, err := unmarshalBackgroundFill(d)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundFill on array item %d: %w", idx, err)
}
vs = append(vs, v)
}
return vs, nil
}
// unmarshalBackgroundFill is a JSON unmarshal helper to marshal the right structs into a BackgroundFill interface
// based on the Type field.
func unmarshalBackgroundFill(d json.RawMessage) (BackgroundFill, error) {
if len(d) == 0 {
return nil, nil
}
t := struct {
Type string
}{}
err := json.Unmarshal(d, &t)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundFill for constant field 'Type': %w", err)
}
switch t.Type {
case "solid":
s := BackgroundFillSolid{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundFill for value 'solid': %w", err)
}
return s, nil
case "gradient":
s := BackgroundFillGradient{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundFill for value 'gradient': %w", err)
}
return s, nil
case "freeform_gradient":
s := BackgroundFillFreeformGradient{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundFill for value 'freeform_gradient': %w", err)
}
return s, nil
}
return nil, fmt.Errorf("unknown interface for BackgroundFill with Type %v", t.Type)
}
// BackgroundFillFreeformGradient (https://core.telegram.org/bots/api#backgroundfillfreeformgradient)
//
// The background is a freeform gradient that rotates after every message in the chat.
type BackgroundFillFreeformGradient struct {
// A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
Colors []int64 `json:"colors,omitempty"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundFillFreeformGradient) GetType() string {
return "freeform_gradient"
}
// MergeBackgroundFill returns a MergedBackgroundFill struct to simplify working with types in a non-generic world.
func (v BackgroundFillFreeformGradient) MergeBackgroundFill() MergedBackgroundFill {
return MergedBackgroundFill{
Type: "freeform_gradient",
Colors: v.Colors,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundFillFreeformGradient) MarshalJSON() ([]byte, error) {
type alias BackgroundFillFreeformGradient
a := struct {
Type string `json:"type"`
alias
}{
Type: "freeform_gradient",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundFillFreeformGradient.backgroundFill is a dummy method to avoid interface implementation.
func (v BackgroundFillFreeformGradient) backgroundFill() {}
// BackgroundFillGradient (https://core.telegram.org/bots/api#backgroundfillgradient)
//
// The background is a gradient fill.
type BackgroundFillGradient struct {
// Top color of the gradient in the RGB24 format
TopColor int64 `json:"top_color"`
// Bottom color of the gradient in the RGB24 format
BottomColor int64 `json:"bottom_color"`
// Clockwise rotation angle of the background fill in degrees; 0-359
RotationAngle int64 `json:"rotation_angle"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundFillGradient) GetType() string {
return "gradient"
}
// MergeBackgroundFill returns a MergedBackgroundFill struct to simplify working with types in a non-generic world.
func (v BackgroundFillGradient) MergeBackgroundFill() MergedBackgroundFill {
return MergedBackgroundFill{
Type: "gradient",
TopColor: v.TopColor,
BottomColor: v.BottomColor,
RotationAngle: v.RotationAngle,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundFillGradient) MarshalJSON() ([]byte, error) {
type alias BackgroundFillGradient
a := struct {
Type string `json:"type"`
alias
}{
Type: "gradient",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundFillGradient.backgroundFill is a dummy method to avoid interface implementation.
func (v BackgroundFillGradient) backgroundFill() {}
// BackgroundFillSolid (https://core.telegram.org/bots/api#backgroundfillsolid)
//
// The background is filled using the selected color.
type BackgroundFillSolid struct {
// The color of the background fill in the RGB24 format
Color int64 `json:"color"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundFillSolid) GetType() string {
return "solid"
}
// MergeBackgroundFill returns a MergedBackgroundFill struct to simplify working with types in a non-generic world.
func (v BackgroundFillSolid) MergeBackgroundFill() MergedBackgroundFill {
return MergedBackgroundFill{
Type: "solid",
Color: v.Color,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundFillSolid) MarshalJSON() ([]byte, error) {
type alias BackgroundFillSolid
a := struct {
Type string `json:"type"`
alias
}{
Type: "solid",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundFillSolid.backgroundFill is a dummy method to avoid interface implementation.
func (v BackgroundFillSolid) backgroundFill() {}
// BackgroundType (https://core.telegram.org/bots/api#backgroundtype)
//
// This object describes the type of a background. Currently, it can be one of
// - BackgroundTypeFill
// - BackgroundTypeWallpaper
// - BackgroundTypePattern
// - BackgroundTypeChatTheme
type BackgroundType interface {
GetType() string
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with complex telegram types in a non-generic world.
MergeBackgroundType() MergedBackgroundType
// backgroundType exists to avoid external types implementing this interface.
backgroundType()
}
// Ensure that all subtypes correctly implement the parent interface.
var (
_ BackgroundType = BackgroundTypeFill{}
_ BackgroundType = BackgroundTypeWallpaper{}
_ BackgroundType = BackgroundTypePattern{}
_ BackgroundType = BackgroundTypeChatTheme{}
)
// MergedBackgroundType is a helper type to simplify interactions with the various BackgroundType subtypes.
type MergedBackgroundType struct {
// Type of the background
Type string `json:"type"`
// Optional. The background fill (Only for fill, pattern)
Fill BackgroundFill `json:"fill,omitempty"`
// Optional. Dimming of the background in dark themes, as a percentage; 0-100 (Only for fill, wallpaper)
DarkThemeDimming int64 `json:"dark_theme_dimming,omitempty"`
// Optional. Document with the wallpaper (Only for wallpaper, pattern)
Document *Document `json:"document,omitempty"`
// Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 (Only for wallpaper)
IsBlurred bool `json:"is_blurred,omitempty"`
// Optional. True, if the background moves slightly when the device is tilted (Only for wallpaper, pattern)
IsMoving bool `json:"is_moving,omitempty"`
// Optional. Intensity of the pattern when it is shown above the filled background; 0-100 (Only for pattern)
Intensity int64 `json:"intensity,omitempty"`
// Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only (Only for pattern)
IsInverted bool `json:"is_inverted,omitempty"`
// Optional. Name of the chat theme, which is usually an emoji (Only for chat_theme)
ThemeName string `json:"theme_name,omitempty"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v MergedBackgroundType) GetType() string {
return v.Type
}
// MergedBackgroundType.backgroundType is a dummy method to avoid interface implementation.
func (v MergedBackgroundType) backgroundType() {}
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with types in a non-generic world.
func (v MergedBackgroundType) MergeBackgroundType() MergedBackgroundType {
return v
}
// unmarshalBackgroundTypeArray is a JSON unmarshalling helper which allows unmarshalling an array of interfaces
// using unmarshalBackgroundType.
func unmarshalBackgroundTypeArray(d json.RawMessage) ([]BackgroundType, error) {
if len(d) == 0 {
return nil, nil
}
var ds []json.RawMessage
err := json.Unmarshal(d, &ds)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal initial BackgroundType JSON into an array: %w", err)
}
var vs []BackgroundType
for idx, d := range ds {
v, err := unmarshalBackgroundType(d)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType on array item %d: %w", idx, err)
}
vs = append(vs, v)
}
return vs, nil
}
// unmarshalBackgroundType is a JSON unmarshal helper to marshal the right structs into a BackgroundType interface
// based on the Type field.
func unmarshalBackgroundType(d json.RawMessage) (BackgroundType, error) {
if len(d) == 0 {
return nil, nil
}
t := struct {
Type string
}{}
err := json.Unmarshal(d, &t)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType for constant field 'Type': %w", err)
}
switch t.Type {
case "fill":
s := BackgroundTypeFill{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType for value 'fill': %w", err)
}
return s, nil
case "wallpaper":
s := BackgroundTypeWallpaper{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType for value 'wallpaper': %w", err)
}
return s, nil
case "pattern":
s := BackgroundTypePattern{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType for value 'pattern': %w", err)
}
return s, nil
case "chat_theme":
s := BackgroundTypeChatTheme{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal BackgroundType for value 'chat_theme': %w", err)
}
return s, nil
}
return nil, fmt.Errorf("unknown interface for BackgroundType with Type %v", t.Type)
}
// BackgroundTypeChatTheme (https://core.telegram.org/bots/api#backgroundtypechattheme)
//
// The background is taken directly from a built-in chat theme.
type BackgroundTypeChatTheme struct {
// Name of the chat theme, which is usually an emoji
ThemeName string `json:"theme_name"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundTypeChatTheme) GetType() string {
return "chat_theme"
}
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with types in a non-generic world.
func (v BackgroundTypeChatTheme) MergeBackgroundType() MergedBackgroundType {
return MergedBackgroundType{
Type: "chat_theme",
ThemeName: v.ThemeName,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundTypeChatTheme) MarshalJSON() ([]byte, error) {
type alias BackgroundTypeChatTheme
a := struct {
Type string `json:"type"`
alias
}{
Type: "chat_theme",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundTypeChatTheme.backgroundType is a dummy method to avoid interface implementation.
func (v BackgroundTypeChatTheme) backgroundType() {}
// BackgroundTypeFill (https://core.telegram.org/bots/api#backgroundtypefill)
//
// The background is automatically filled based on the selected colors.
type BackgroundTypeFill struct {
// The background fill
Fill BackgroundFill `json:"fill"`
// Dimming of the background in dark themes, as a percentage; 0-100
DarkThemeDimming int64 `json:"dark_theme_dimming"`
}
// UnmarshalJSON is a custom JSON unmarshaller to use the helpers which allow for unmarshalling structs into interfaces.
func (v *BackgroundTypeFill) UnmarshalJSON(b []byte) error {
// All fields in BackgroundTypeFill, with interface fields as json.RawMessage
type tmp struct {
Fill json.RawMessage `json:"fill"`
DarkThemeDimming int64 `json:"dark_theme_dimming"`
}
t := tmp{}
err := json.Unmarshal(b, &t)
if err != nil {
return fmt.Errorf("failed to unmarshal BackgroundTypeFill JSON into tmp struct: %w", err)
}
v.Fill, err = unmarshalBackgroundFill(t.Fill)
if err != nil {
return fmt.Errorf("failed to unmarshal custom JSON field Fill: %w", err)
}
v.DarkThemeDimming = t.DarkThemeDimming
return nil
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundTypeFill) GetType() string {
return "fill"
}
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with types in a non-generic world.
func (v BackgroundTypeFill) MergeBackgroundType() MergedBackgroundType {
return MergedBackgroundType{
Type: "fill",
Fill: v.Fill,
DarkThemeDimming: v.DarkThemeDimming,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundTypeFill) MarshalJSON() ([]byte, error) {
type alias BackgroundTypeFill
a := struct {
Type string `json:"type"`
alias
}{
Type: "fill",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundTypeFill.backgroundType is a dummy method to avoid interface implementation.
func (v BackgroundTypeFill) backgroundType() {}
// BackgroundTypePattern (https://core.telegram.org/bots/api#backgroundtypepattern)
//
// The background is a PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user.
type BackgroundTypePattern struct {
// Document with the pattern
Document Document `json:"document"`
// The background fill that is combined with the pattern
Fill BackgroundFill `json:"fill"`
// Intensity of the pattern when it is shown above the filled background; 0-100
Intensity int64 `json:"intensity"`
// Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only
IsInverted bool `json:"is_inverted,omitempty"`
// Optional. True, if the background moves slightly when the device is tilted
IsMoving bool `json:"is_moving,omitempty"`
}
// UnmarshalJSON is a custom JSON unmarshaller to use the helpers which allow for unmarshalling structs into interfaces.
func (v *BackgroundTypePattern) UnmarshalJSON(b []byte) error {
// All fields in BackgroundTypePattern, with interface fields as json.RawMessage
type tmp struct {
Document Document `json:"document"`
Fill json.RawMessage `json:"fill"`
Intensity int64 `json:"intensity"`
IsInverted bool `json:"is_inverted"`
IsMoving bool `json:"is_moving"`
}
t := tmp{}
err := json.Unmarshal(b, &t)
if err != nil {
return fmt.Errorf("failed to unmarshal BackgroundTypePattern JSON into tmp struct: %w", err)
}
v.Document = t.Document
v.Fill, err = unmarshalBackgroundFill(t.Fill)
if err != nil {
return fmt.Errorf("failed to unmarshal custom JSON field Fill: %w", err)
}
v.Intensity = t.Intensity
v.IsInverted = t.IsInverted
v.IsMoving = t.IsMoving
return nil
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundTypePattern) GetType() string {
return "pattern"
}
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with types in a non-generic world.
func (v BackgroundTypePattern) MergeBackgroundType() MergedBackgroundType {
return MergedBackgroundType{
Type: "pattern",
Document: &v.Document,
Fill: v.Fill,
Intensity: v.Intensity,
IsInverted: v.IsInverted,
IsMoving: v.IsMoving,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundTypePattern) MarshalJSON() ([]byte, error) {
type alias BackgroundTypePattern
a := struct {
Type string `json:"type"`
alias
}{
Type: "pattern",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundTypePattern.backgroundType is a dummy method to avoid interface implementation.
func (v BackgroundTypePattern) backgroundType() {}
// BackgroundTypeWallpaper (https://core.telegram.org/bots/api#backgroundtypewallpaper)
//
// The background is a wallpaper in the JPEG format.
type BackgroundTypeWallpaper struct {
// Document with the wallpaper
Document Document `json:"document"`
// Dimming of the background in dark themes, as a percentage; 0-100
DarkThemeDimming int64 `json:"dark_theme_dimming"`
// Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
IsBlurred bool `json:"is_blurred,omitempty"`
// Optional. True, if the background moves slightly when the device is tilted
IsMoving bool `json:"is_moving,omitempty"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BackgroundTypeWallpaper) GetType() string {
return "wallpaper"
}
// MergeBackgroundType returns a MergedBackgroundType struct to simplify working with types in a non-generic world.
func (v BackgroundTypeWallpaper) MergeBackgroundType() MergedBackgroundType {
return MergedBackgroundType{
Type: "wallpaper",
Document: &v.Document,
DarkThemeDimming: v.DarkThemeDimming,
IsBlurred: v.IsBlurred,
IsMoving: v.IsMoving,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BackgroundTypeWallpaper) MarshalJSON() ([]byte, error) {
type alias BackgroundTypeWallpaper
a := struct {
Type string `json:"type"`
alias
}{
Type: "wallpaper",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BackgroundTypeWallpaper.backgroundType is a dummy method to avoid interface implementation.
func (v BackgroundTypeWallpaper) backgroundType() {}
// Birthdate (https://core.telegram.org/bots/api#birthdate)
//
// Describes the birthdate of a user.
type Birthdate struct {
// Day of the user's birth; 1-31
Day int64 `json:"day"`
// Month of the user's birth; 1-12
Month int64 `json:"month"`
// Optional. Year of the user's birth
Year int64 `json:"year,omitempty"`
}
// BotCommand (https://core.telegram.org/bots/api#botcommand)
//
// This object represents a bot command.
type BotCommand struct {
// Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
Command string `json:"command"`
// Description of the command; 1-256 characters.
Description string `json:"description"`
}
// BotCommandScope (https://core.telegram.org/bots/api#botcommandscope)
//
// This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported:
// - BotCommandScopeDefault
// - BotCommandScopeAllPrivateChats
// - BotCommandScopeAllGroupChats
// - BotCommandScopeAllChatAdministrators
// - BotCommandScopeChat
// - BotCommandScopeChatAdministrators
// - BotCommandScopeChatMember
type BotCommandScope interface {
GetType() string
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with complex telegram types in a non-generic world.
MergeBotCommandScope() MergedBotCommandScope
// botCommandScope exists to avoid external types implementing this interface.
botCommandScope()
}
// Ensure that all subtypes correctly implement the parent interface.
var (
_ BotCommandScope = BotCommandScopeDefault{}
_ BotCommandScope = BotCommandScopeAllPrivateChats{}
_ BotCommandScope = BotCommandScopeAllGroupChats{}
_ BotCommandScope = BotCommandScopeAllChatAdministrators{}
_ BotCommandScope = BotCommandScopeChat{}
_ BotCommandScope = BotCommandScopeChatAdministrators{}
_ BotCommandScope = BotCommandScopeChatMember{}
)
// MergedBotCommandScope is a helper type to simplify interactions with the various BotCommandScope subtypes.
type MergedBotCommandScope struct {
// Scope type
Type string `json:"type"`
// Optional. Unique identifier for the target chat (Only for chat, chat_administrators, chat_member)
ChatId int64 `json:"chat_id,omitempty"`
// Optional. Unique identifier of the target user (Only for chat_member)
UserId int64 `json:"user_id,omitempty"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v MergedBotCommandScope) GetType() string {
return v.Type
}
// MergedBotCommandScope.botCommandScope is a dummy method to avoid interface implementation.
func (v MergedBotCommandScope) botCommandScope() {}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v MergedBotCommandScope) MergeBotCommandScope() MergedBotCommandScope {
return v
}
// BotCommandScopeAllChatAdministrators (https://core.telegram.org/bots/api#botcommandscopeallchatadministrators)
//
// Represents the scope of bot commands, covering all group and supergroup chat administrators.
type BotCommandScopeAllChatAdministrators struct{}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeAllChatAdministrators) GetType() string {
return "all_chat_administrators"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeAllChatAdministrators) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "all_chat_administrators",
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeAllChatAdministrators) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeAllChatAdministrators
a := struct {
Type string `json:"type"`
alias
}{
Type: "all_chat_administrators",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeAllChatAdministrators.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeAllChatAdministrators) botCommandScope() {}
// BotCommandScopeAllGroupChats (https://core.telegram.org/bots/api#botcommandscopeallgroupchats)
//
// Represents the scope of bot commands, covering all group and supergroup chats.
type BotCommandScopeAllGroupChats struct{}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeAllGroupChats) GetType() string {
return "all_group_chats"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeAllGroupChats) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "all_group_chats",
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeAllGroupChats) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeAllGroupChats
a := struct {
Type string `json:"type"`
alias
}{
Type: "all_group_chats",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeAllGroupChats.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeAllGroupChats) botCommandScope() {}
// BotCommandScopeAllPrivateChats (https://core.telegram.org/bots/api#botcommandscopeallprivatechats)
//
// Represents the scope of bot commands, covering all private chats.
type BotCommandScopeAllPrivateChats struct{}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeAllPrivateChats) GetType() string {
return "all_private_chats"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeAllPrivateChats) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "all_private_chats",
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeAllPrivateChats) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeAllPrivateChats
a := struct {
Type string `json:"type"`
alias
}{
Type: "all_private_chats",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeAllPrivateChats.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeAllPrivateChats) botCommandScope() {}
// BotCommandScopeChat (https://core.telegram.org/bots/api#botcommandscopechat)
//
// Represents the scope of bot commands, covering a specific chat.
type BotCommandScopeChat struct {
// Unique identifier for the target chat
ChatId int64 `json:"chat_id"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeChat) GetType() string {
return "chat"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeChat) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "chat",
ChatId: v.ChatId,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeChat) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeChat
a := struct {
Type string `json:"type"`
alias
}{
Type: "chat",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeChat.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeChat) botCommandScope() {}
// BotCommandScopeChatAdministrators (https://core.telegram.org/bots/api#botcommandscopechatadministrators)
//
// Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
type BotCommandScopeChatAdministrators struct {
// Unique identifier for the target chat
ChatId int64 `json:"chat_id"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeChatAdministrators) GetType() string {
return "chat_administrators"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeChatAdministrators) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "chat_administrators",
ChatId: v.ChatId,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeChatAdministrators) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeChatAdministrators
a := struct {
Type string `json:"type"`
alias
}{
Type: "chat_administrators",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeChatAdministrators.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeChatAdministrators) botCommandScope() {}
// BotCommandScopeChatMember (https://core.telegram.org/bots/api#botcommandscopechatmember)
//
// Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
type BotCommandScopeChatMember struct {
// Unique identifier for the target chat
ChatId int64 `json:"chat_id"`
// Unique identifier of the target user
UserId int64 `json:"user_id"`
}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeChatMember) GetType() string {
return "chat_member"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeChatMember) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "chat_member",
ChatId: v.ChatId,
UserId: v.UserId,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeChatMember) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeChatMember
a := struct {
Type string `json:"type"`
alias
}{
Type: "chat_member",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeChatMember.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeChatMember) botCommandScope() {}
// BotCommandScopeDefault (https://core.telegram.org/bots/api#botcommandscopedefault)
//
// Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.
type BotCommandScopeDefault struct{}
// GetType is a helper method to easily access the common fields of an interface.
func (v BotCommandScopeDefault) GetType() string {
return "default"
}
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with types in a non-generic world.
func (v BotCommandScopeDefault) MergeBotCommandScope() MergedBotCommandScope {
return MergedBotCommandScope{
Type: "default",
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value.
func (v BotCommandScopeDefault) MarshalJSON() ([]byte, error) {
type alias BotCommandScopeDefault
a := struct {
Type string `json:"type"`
alias
}{
Type: "default",
alias: (alias)(v),
}
return json.Marshal(a)
}
// BotCommandScopeDefault.botCommandScope is a dummy method to avoid interface implementation.
func (v BotCommandScopeDefault) botCommandScope() {}
// BotDescription (https://core.telegram.org/bots/api#botdescription)
//
// This object represents the bot's description.
type BotDescription struct {
// The bot's description
Description string `json:"description"`
}
// BotName (https://core.telegram.org/bots/api#botname)
//
// This object represents the bot's name.
type BotName struct {
// The bot's name
Name string `json:"name"`
}