forked from PaulSonOfLars/gotgbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_types.go
executable file
·4962 lines (4486 loc) · 232 KB
/
gen_types.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
// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
// Regen by running 'go generate' in the repo root.
package gotgbot
import (
"encoding/json"
"fmt"
"io"
)
type ReplyMarkup interface {
replyMarkup()
}
// Animation This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
// https://core.telegram.org/bots/api#animation
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 sender
Width int64 `json:"width"`
// Video height as defined by sender
Height int64 `json:"height"`
// Duration of the video in seconds as defined by sender
Duration int64 `json:"duration"`
// Optional. Animation thumbnail as defined by sender
Thumb *PhotoSize `json:"thumb,omitempty"`
// Optional. Original animation filename as defined by sender
FileName string `json:"file_name,omitempty"`
// Optional. MIME type of the file as defined by 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 This object represents an audio file to be treated as music by the Telegram clients.
// https://core.telegram.org/bots/api#audio
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 sender
Duration int64 `json:"duration"`
// Optional. Performer of the audio as defined by sender or by audio tags
Performer string `json:"performer,omitempty"`
// Optional. Title of the audio as defined by sender or by audio tags
Title string `json:"title,omitempty"`
// Optional. Original filename as defined by sender
FileName string `json:"file_name,omitempty"`
// Optional. MIME type of the file as defined by 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
Thumb *PhotoSize `json:"thumb,omitempty"`
}
// BotCommand This object represents a bot command.
// https://core.telegram.org/bots/api#botcommand
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 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
// https://core.telegram.org/bots/api#botcommandscope
type BotCommandScope interface {
GetType() string
botCommandScope()
// MergeBotCommandScope returns a MergedBotCommandScope struct to simplify working with complex telegram types in a non-generic world.
MergeBotCommandScope() MergedBotCommandScope
}
// MergedBotCommandScope is a helper type to simplify interactions with the various BotCommandScope subtypes.
type MergedBotCommandScope struct {
// Scope type, must be default
Type string `json:"type"`
// Optional. Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) (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 Represents the scope of bot commands, covering all group and supergroup chat administrators.
// https://core.telegram.org/bots/api#botcommandscopeallchatadministrators
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 Represents the scope of bot commands, covering all group and supergroup chats.
// https://core.telegram.org/bots/api#botcommandscopeallgroupchats
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 Represents the scope of bot commands, covering all private chats.
// https://core.telegram.org/bots/api#botcommandscopeallprivatechats
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 Represents the scope of bot commands, covering a specific chat.
// https://core.telegram.org/bots/api#botcommandscopechat
type BotCommandScopeChat struct {
// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
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 Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
// https://core.telegram.org/bots/api#botcommandscopechatadministrators
type BotCommandScopeChatAdministrators struct {
// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
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 Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
// https://core.telegram.org/bots/api#botcommandscopechatmember
type BotCommandScopeChatMember struct {
// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
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 Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.
// https://core.telegram.org/bots/api#botcommandscopedefault
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() {}
// CallbackGame A placeholder, currently holds no information. Use BotFather to set up your game.
// https://core.telegram.org/bots/api#callbackgame
type CallbackGame struct{}
// CallbackQuery This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
// https://core.telegram.org/bots/api#callbackquery
type CallbackQuery struct {
// Unique identifier for this query
Id string `json:"id"`
// Sender
From User `json:"from"`
// Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old
Message *Message `json:"message,omitempty"`
// Optional. Identifier of the message sent via the bot in inline mode, that originated the query.
InlineMessageId string `json:"inline_message_id,omitempty"`
// Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.
ChatInstance string `json:"chat_instance"`
// Optional. Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data.
Data string `json:"data,omitempty"`
// Optional. Short name of a Game to be returned, serves as the unique identifier for the game
GameShortName string `json:"game_short_name,omitempty"`
}
// Chat This object represents a chat.
// https://core.telegram.org/bots/api#chat
type Chat struct {
// Unique identifier for this chat. This number may have more than 32 significant bits 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 identifier.
Id int64 `json:"id"`
// Type of chat, can be either "private", "group", "supergroup" or "channel"
Type string `json:"type"`
// Optional. Title, for supergroups, channels and group chats
Title string `json:"title,omitempty"`
// Optional. Username, for private chats, supergroups and channels if available
Username string `json:"username,omitempty"`
// Optional. First name of the other party in a private chat
FirstName string `json:"first_name,omitempty"`
// Optional. Last name of the other party in a private chat
LastName string `json:"last_name,omitempty"`
// Optional. True, if the supergroup chat is a forum (has topics enabled)
IsForum bool `json:"is_forum,omitempty"`
// Optional. Chat photo. Returned only in getChat.
Photo *ChatPhoto `json:"photo,omitempty"`
// Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.
ActiveUsernames []string `json:"active_usernames,omitempty"`
// Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
EmojiStatusCustomEmojiId string `json:"emoji_status_custom_emoji_id,omitempty"`
// Optional. Bio of the other party in a private chat. Returned only in getChat.
Bio string `json:"bio,omitempty"`
// Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user. Returned only in getChat.
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
// Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat.
HasRestrictedVoiceAndVideoMessages bool `json:"has_restricted_voice_and_video_messages,omitempty"`
// Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat.
JoinToSendMessages bool `json:"join_to_send_messages,omitempty"`
// Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.
JoinByRequest bool `json:"join_by_request,omitempty"`
// Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.
Description string `json:"description,omitempty"`
// Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
InviteLink string `json:"invite_link,omitempty"`
// Optional. The most recent pinned message (by sending date). Returned only in getChat.
PinnedMessage *Message `json:"pinned_message,omitempty"`
// Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
Permissions *ChatPermissions `json:"permissions,omitempty"`
// Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat.
SlowModeDelay int64 `json:"slow_mode_delay,omitempty"`
// Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
MessageAutoDeleteTime int64 `json:"message_auto_delete_time,omitempty"`
// Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
HasProtectedContent bool `json:"has_protected_content,omitempty"`
// Optional. For supergroups, name of group sticker set. Returned only in getChat.
StickerSetName string `json:"sticker_set_name,omitempty"`
// Optional. True, if the bot can change the group sticker set. Returned only in getChat.
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
// Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.
LinkedChatId int64 `json:"linked_chat_id,omitempty"`
// Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
Location *ChatLocation `json:"location,omitempty"`
}
// ChatAdministratorRights Represents the rights of an administrator in a chat.
// https://core.telegram.org/bots/api#chatadministratorrights
type ChatAdministratorRights struct {
// True, if the user's presence in the chat is hidden
IsAnonymous bool `json:"is_anonymous"`
// True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
CanManageChat bool `json:"can_manage_chat"`
// True, if the administrator can delete messages of other users
CanDeleteMessages bool `json:"can_delete_messages"`
// True, if the administrator can manage video chats
CanManageVideoChats bool `json:"can_manage_video_chats"`
// True, if the administrator can restrict, ban or unban chat members
CanRestrictMembers bool `json:"can_restrict_members"`
// True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
CanPromoteMembers bool `json:"can_promote_members"`
// True, if the user is allowed to change the chat title, photo and other settings
CanChangeInfo bool `json:"can_change_info"`
// True, if the user is allowed to invite new users to the chat
CanInviteUsers bool `json:"can_invite_users"`
// Optional. True, if the administrator can post in the channel; channels only
CanPostMessages bool `json:"can_post_messages,omitempty"`
// Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
CanEditMessages bool `json:"can_edit_messages,omitempty"`
// Optional. True, if the user is allowed to pin messages; groups and supergroups only
CanPinMessages bool `json:"can_pin_messages,omitempty"`
// Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
CanManageTopics bool `json:"can_manage_topics,omitempty"`
}
// ChatInviteLink Represents an invite link for a chat.
// https://core.telegram.org/bots/api#chatinvitelink
type ChatInviteLink struct {
// The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with "...".
InviteLink string `json:"invite_link"`
// Creator of the link
Creator User `json:"creator"`
// True, if users joining the chat via the link need to be approved by chat administrators
CreatesJoinRequest bool `json:"creates_join_request"`
// True, if the link is primary
IsPrimary bool `json:"is_primary"`
// True, if the link is revoked
IsRevoked bool `json:"is_revoked"`
// Optional. Invite link name
Name string `json:"name,omitempty"`
// Optional. Point in time (Unix timestamp) when the link will expire or has been expired
ExpireDate int64 `json:"expire_date,omitempty"`
// Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
MemberLimit int64 `json:"member_limit,omitempty"`
// Optional. Number of pending join requests created using this link
PendingJoinRequestCount int64 `json:"pending_join_request_count,omitempty"`
}
// ChatJoinRequest Represents a join request sent to a chat.
// https://core.telegram.org/bots/api#chatjoinrequest
type ChatJoinRequest struct {
// Chat to which the request was sent
Chat Chat `json:"chat"`
// User that sent the join request
From User `json:"from"`
// Date the request was sent in Unix time
Date int64 `json:"date"`
// Optional. Bio of the user.
Bio string `json:"bio,omitempty"`
// Optional. Chat invite link that was used by the user to send the join request
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
}
// ChatLocation Represents a location to which a chat is connected.
// https://core.telegram.org/bots/api#chatlocation
type ChatLocation struct {
// The location to which the supergroup is connected. Can't be a live location.
Location Location `json:"location"`
// Location address; 1-64 characters, as defined by the chat owner
Address string `json:"address"`
}
// ChatMember This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported:
// - ChatMemberOwner
// - ChatMemberAdministrator
// - ChatMemberMember
// - ChatMemberRestricted
// - ChatMemberLeft
// - ChatMemberBanned
// https://core.telegram.org/bots/api#chatmember
type ChatMember interface {
GetStatus() string
GetUser() User
chatMember()
// MergeChatMember returns a MergedChatMember struct to simplify working with complex telegram types in a non-generic world.
MergeChatMember() MergedChatMember
}
// MergedChatMember is a helper type to simplify interactions with the various ChatMember subtypes.
type MergedChatMember struct {
// The member's status in the chat, always "creator"
Status string `json:"status"`
// Information about the user
User User `json:"user"`
// Optional. True, if the user's presence in the chat is hidden (Only for creator, administrator)
IsAnonymous bool `json:"is_anonymous,omitempty"`
// Optional. Custom title for this user (Only for creator, administrator)
CustomTitle string `json:"custom_title,omitempty"`
// Optional. True, if the bot is allowed to edit administrator privileges of that user (Only for administrator)
CanBeEdited bool `json:"can_be_edited,omitempty"`
// Optional. True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege (Only for administrator)
CanManageChat bool `json:"can_manage_chat,omitempty"`
// Optional. True, if the administrator can delete messages of other users (Only for administrator)
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
// Optional. True, if the administrator can manage video chats (Only for administrator)
CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
// Optional. True, if the administrator can restrict, ban or unban chat members (Only for administrator)
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
// Optional. True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) (Only for administrator)
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
// Optional. True, if the user is allowed to change the chat title, photo and other settings (Only for administrator, restricted)
CanChangeInfo bool `json:"can_change_info,omitempty"`
// Optional. True, if the user is allowed to invite new users to the chat (Only for administrator, restricted)
CanInviteUsers bool `json:"can_invite_users,omitempty"`
// Optional. True, if the administrator can post in the channel; channels only (Only for administrator)
CanPostMessages bool `json:"can_post_messages,omitempty"`
// Optional. True, if the administrator can edit messages of other users and can pin messages; channels only (Only for administrator)
CanEditMessages bool `json:"can_edit_messages,omitempty"`
// Optional. True, if the user is allowed to pin messages; groups and supergroups only (Only for administrator, restricted)
CanPinMessages bool `json:"can_pin_messages,omitempty"`
// Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only (Only for administrator, restricted)
CanManageTopics bool `json:"can_manage_topics,omitempty"`
// Optional. True, if the user is a member of the chat at the moment of the request (Only for restricted)
IsMember bool `json:"is_member,omitempty"`
// Optional. True, if the user is allowed to send text messages, contacts, locations and venues (Only for restricted)
CanSendMessages bool `json:"can_send_messages,omitempty"`
// Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes (Only for restricted)
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
// Optional. True, if the user is allowed to send polls (Only for restricted)
CanSendPolls bool `json:"can_send_polls,omitempty"`
// Optional. True, if the user is allowed to send animations, games, stickers and use inline bots (Only for restricted)
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
// Optional. True, if the user is allowed to add web page previews to their messages (Only for restricted)
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
// Optional. Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever (Only for restricted, kicked)
UntilDate int64 `json:"until_date,omitempty"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v MergedChatMember) GetStatus() string {
return v.Status
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v MergedChatMember) GetUser() User {
return v.User
}
// MergedChatMember.chatMember is a dummy method to avoid interface implementation.
func (v MergedChatMember) chatMember() {}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v MergedChatMember) MergeChatMember() MergedChatMember {
return v
}
// unmarshalChatMemberArray is a JSON unmarshalling helper which allows unmarshalling an array of interfaces
// using unmarshalChatMember.
func unmarshalChatMemberArray(d json.RawMessage) ([]ChatMember, error) {
var ds []json.RawMessage
err := json.Unmarshal(d, &ds)
if err != nil {
return nil, err
}
var vs []ChatMember
for _, d := range ds {
v, err := unmarshalChatMember(d)
if err != nil {
return nil, err
}
vs = append(vs, v)
}
return vs, nil
}
// unmarshalChatMember is a JSON unmarshal helper to marshal the right structs into a ChatMember interface
// based on the Status field.
func unmarshalChatMember(d json.RawMessage) (ChatMember, error) {
if len(d) == 0 {
return nil, nil
}
t := struct {
Status string
}{}
err := json.Unmarshal(d, &t)
if err != nil {
return nil, err
}
switch t.Status {
case "creator":
s := ChatMemberOwner{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
case "administrator":
s := ChatMemberAdministrator{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
case "member":
s := ChatMemberMember{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
case "restricted":
s := ChatMemberRestricted{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
case "left":
s := ChatMemberLeft{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
case "kicked":
s := ChatMemberBanned{}
err := json.Unmarshal(d, &s)
if err != nil {
return nil, err
}
return s, nil
}
return nil, fmt.Errorf("unknown interface with Status %v", t.Status)
}
// ChatMemberAdministrator Represents a chat member that has some additional privileges.
// https://core.telegram.org/bots/api#chatmemberadministrator
type ChatMemberAdministrator struct {
// Information about the user
User User `json:"user"`
// True, if the bot is allowed to edit administrator privileges of that user
CanBeEdited bool `json:"can_be_edited"`
// True, if the user's presence in the chat is hidden
IsAnonymous bool `json:"is_anonymous"`
// True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
CanManageChat bool `json:"can_manage_chat"`
// True, if the administrator can delete messages of other users
CanDeleteMessages bool `json:"can_delete_messages"`
// True, if the administrator can manage video chats
CanManageVideoChats bool `json:"can_manage_video_chats"`
// True, if the administrator can restrict, ban or unban chat members
CanRestrictMembers bool `json:"can_restrict_members"`
// True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
CanPromoteMembers bool `json:"can_promote_members"`
// True, if the user is allowed to change the chat title, photo and other settings
CanChangeInfo bool `json:"can_change_info"`
// True, if the user is allowed to invite new users to the chat
CanInviteUsers bool `json:"can_invite_users"`
// Optional. True, if the administrator can post in the channel; channels only
CanPostMessages bool `json:"can_post_messages,omitempty"`
// Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
CanEditMessages bool `json:"can_edit_messages,omitempty"`
// Optional. True, if the user is allowed to pin messages; groups and supergroups only
CanPinMessages bool `json:"can_pin_messages,omitempty"`
// Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
CanManageTopics bool `json:"can_manage_topics,omitempty"`
// Optional. Custom title for this user
CustomTitle string `json:"custom_title,omitempty"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberAdministrator) GetStatus() string {
return "administrator"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberAdministrator) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberAdministrator) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "administrator",
User: v.User,
CanBeEdited: v.CanBeEdited,
IsAnonymous: v.IsAnonymous,
CanManageChat: v.CanManageChat,
CanDeleteMessages: v.CanDeleteMessages,
CanManageVideoChats: v.CanManageVideoChats,
CanRestrictMembers: v.CanRestrictMembers,
CanPromoteMembers: v.CanPromoteMembers,
CanChangeInfo: v.CanChangeInfo,
CanInviteUsers: v.CanInviteUsers,
CanPostMessages: v.CanPostMessages,
CanEditMessages: v.CanEditMessages,
CanPinMessages: v.CanPinMessages,
CanManageTopics: v.CanManageTopics,
CustomTitle: v.CustomTitle,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberAdministrator) MarshalJSON() ([]byte, error) {
type alias ChatMemberAdministrator
a := struct {
Status string `json:"status"`
alias
}{
Status: "administrator",
alias: (alias)(v),
}
return json.Marshal(a)
}
// ChatMemberAdministrator.chatMember is a dummy method to avoid interface implementation.
func (v ChatMemberAdministrator) chatMember() {}
// ChatMemberBanned Represents a chat member that was banned in the chat and can't return to the chat or view chat messages.
// https://core.telegram.org/bots/api#chatmemberbanned
type ChatMemberBanned struct {
// Information about the user
User User `json:"user"`
// Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever
UntilDate int64 `json:"until_date"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberBanned) GetStatus() string {
return "kicked"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberBanned) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberBanned) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "kicked",
User: v.User,
UntilDate: v.UntilDate,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberBanned) MarshalJSON() ([]byte, error) {
type alias ChatMemberBanned
a := struct {
Status string `json:"status"`
alias
}{
Status: "kicked",
alias: (alias)(v),
}
return json.Marshal(a)
}
// ChatMemberBanned.chatMember is a dummy method to avoid interface implementation.
func (v ChatMemberBanned) chatMember() {}
// ChatMemberLeft Represents a chat member that isn't currently a member of the chat, but may join it themselves.
// https://core.telegram.org/bots/api#chatmemberleft
type ChatMemberLeft struct {
// Information about the user
User User `json:"user"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberLeft) GetStatus() string {
return "left"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberLeft) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberLeft) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "left",
User: v.User,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberLeft) MarshalJSON() ([]byte, error) {
type alias ChatMemberLeft
a := struct {
Status string `json:"status"`
alias
}{
Status: "left",
alias: (alias)(v),
}
return json.Marshal(a)
}
// ChatMemberLeft.chatMember is a dummy method to avoid interface implementation.
func (v ChatMemberLeft) chatMember() {}
// ChatMemberMember Represents a chat member that has no additional privileges or restrictions.
// https://core.telegram.org/bots/api#chatmembermember
type ChatMemberMember struct {
// Information about the user
User User `json:"user"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberMember) GetStatus() string {
return "member"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberMember) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberMember) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "member",
User: v.User,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberMember) MarshalJSON() ([]byte, error) {
type alias ChatMemberMember
a := struct {
Status string `json:"status"`
alias
}{
Status: "member",
alias: (alias)(v),
}
return json.Marshal(a)
}
// ChatMemberMember.chatMember is a dummy method to avoid interface implementation.
func (v ChatMemberMember) chatMember() {}
// ChatMemberOwner Represents a chat member that owns the chat and has all administrator privileges.
// https://core.telegram.org/bots/api#chatmemberowner
type ChatMemberOwner struct {
// Information about the user
User User `json:"user"`
// True, if the user's presence in the chat is hidden
IsAnonymous bool `json:"is_anonymous"`
// Optional. Custom title for this user
CustomTitle string `json:"custom_title,omitempty"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberOwner) GetStatus() string {
return "creator"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberOwner) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberOwner) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "creator",
User: v.User,
IsAnonymous: v.IsAnonymous,
CustomTitle: v.CustomTitle,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberOwner) MarshalJSON() ([]byte, error) {
type alias ChatMemberOwner
a := struct {
Status string `json:"status"`
alias
}{
Status: "creator",
alias: (alias)(v),
}
return json.Marshal(a)
}
// ChatMemberOwner.chatMember is a dummy method to avoid interface implementation.
func (v ChatMemberOwner) chatMember() {}
// ChatMemberRestricted Represents a chat member that is under certain restrictions in the chat. Supergroups only.
// https://core.telegram.org/bots/api#chatmemberrestricted
type ChatMemberRestricted struct {
// Information about the user
User User `json:"user"`
// True, if the user is a member of the chat at the moment of the request
IsMember bool `json:"is_member"`
// True, if the user is allowed to change the chat title, photo and other settings
CanChangeInfo bool `json:"can_change_info"`
// True, if the user is allowed to invite new users to the chat
CanInviteUsers bool `json:"can_invite_users"`
// True, if the user is allowed to pin messages
CanPinMessages bool `json:"can_pin_messages"`
// True, if the user is allowed to create forum topics
CanManageTopics bool `json:"can_manage_topics"`
// True, if the user is allowed to send text messages, contacts, locations and venues
CanSendMessages bool `json:"can_send_messages"`
// True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
CanSendMediaMessages bool `json:"can_send_media_messages"`
// True, if the user is allowed to send polls
CanSendPolls bool `json:"can_send_polls"`
// True, if the user is allowed to send animations, games, stickers and use inline bots
CanSendOtherMessages bool `json:"can_send_other_messages"`
// True, if the user is allowed to add web page previews to their messages
CanAddWebPagePreviews bool `json:"can_add_web_page_previews"`
// Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever
UntilDate int64 `json:"until_date"`
}
// GetStatus is a helper method to easily access the common fields of an interface.
func (v ChatMemberRestricted) GetStatus() string {
return "restricted"
}
// GetUser is a helper method to easily access the common fields of an interface.
func (v ChatMemberRestricted) GetUser() User {
return v.User
}
// MergeChatMember returns a MergedChatMember struct to simplify working with types in a non-generic world.
func (v ChatMemberRestricted) MergeChatMember() MergedChatMember {
return MergedChatMember{
Status: "restricted",
User: v.User,
IsMember: v.IsMember,
CanChangeInfo: v.CanChangeInfo,
CanInviteUsers: v.CanInviteUsers,
CanPinMessages: v.CanPinMessages,
CanManageTopics: v.CanManageTopics,
CanSendMessages: v.CanSendMessages,
CanSendMediaMessages: v.CanSendMediaMessages,
CanSendPolls: v.CanSendPolls,
CanSendOtherMessages: v.CanSendOtherMessages,
CanAddWebPagePreviews: v.CanAddWebPagePreviews,
UntilDate: v.UntilDate,
}
}
// MarshalJSON is a custom JSON marshaller to allow for enforcing the Status value.
func (v ChatMemberRestricted) MarshalJSON() ([]byte, error) {
type alias ChatMemberRestricted
a := struct {
Status string `json:"status"`
alias
}{
Status: "restricted",
alias: (alias)(v),