Skip to content

Commit 617735e

Browse files
authored
Merge pull request #570 from Olegt0rr/bugs/fix-optional
Omit empty optional fields
2 parents 5278131 + 58adc9b commit 617735e

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

types.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ type Update struct {
101101
// unblocked by the user.
102102
//
103103
// optional
104-
MyChatMember *ChatMemberUpdated `json:"my_chat_member"`
104+
MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
105105
// ChatMember is a chat member's status was updated in a chat. The bot must
106106
// be an administrator in the chat and must explicitly specify "chat_member"
107107
// in the list of allowed_updates to receive these updates.
108108
//
109109
// optional
110-
ChatMember *ChatMemberUpdated `json:"chat_member"`
110+
ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
111111
// ChatJoinRequest is a request to join the chat has been sent. The bot must
112112
// have the can_invite_users administrator right in the chat to receive
113113
// these updates.
114114
//
115115
// optional
116-
ChatJoinRequest *ChatJoinRequest `json:"chat_join_request"`
116+
ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`
117117
}
118118

119119
// SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
@@ -325,7 +325,7 @@ type Chat struct {
325325
// connected. Returned only in getChat.
326326
//
327327
// optional
328-
Location *ChatLocation `json:"location"`
328+
Location *ChatLocation `json:"location,omitempty"`
329329
}
330330

331331
// IsPrivate returns if the Chat is a private conversation.
@@ -553,7 +553,7 @@ type Message struct {
553553
// settings changed in the chat.
554554
//
555555
// optional
556-
MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed"`
556+
MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`
557557
// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
558558
// This number may be greater than 32 bits and some programming languages
559559
// may have difficulty/silent defects in interpreting it.
@@ -598,28 +598,28 @@ type Message struct {
598598
// triggered another user's proximity alert while sharing Live Location
599599
//
600600
// optional
601-
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"`
601+
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
602602
// VideoChatScheduled is a service message: video chat scheduled.
603603
//
604604
// optional
605-
VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled"`
605+
VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"`
606606
// VideoChatStarted is a service message: video chat started.
607607
//
608608
// optional
609-
VideoChatStarted *VideoChatStarted `json:"video_chat_started"`
609+
VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"`
610610
// VideoChatEnded is a service message: video chat ended.
611611
//
612612
// optional
613-
VideoChatEnded *VideoChatEnded `json:"video_chat_ended"`
613+
VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"`
614614
// VideoChatParticipantsInvited is a service message: new participants
615615
// invited to a video chat.
616616
//
617617
// optional
618-
VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited"`
618+
VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited,omitempty"`
619619
// WebAppData is a service message: data sent by a Web App.
620620
//
621621
// optional
622-
WebAppData *WebAppData `json:"web_app_data"`
622+
WebAppData *WebAppData `json:"web_app_data,omitempty"`
623623
// ReplyMarkup is the Inline keyboard attached to the message.
624624
// login_url buttons are represented as ordinary url buttons.
625625
//
@@ -1202,7 +1202,7 @@ type VideoChatParticipantsInvited struct {
12021202
// New members that were invited to the voice chat.
12031203
//
12041204
// optional
1205-
Users []User `json:"users"`
1205+
Users []User `json:"users,omitempty"`
12061206
}
12071207

12081208
// UserProfilePhotos contains a set of user profile photos.
@@ -1544,30 +1544,30 @@ type ChatInviteLink struct {
15441544
// be approved by chat administrators.
15451545
//
15461546
// optional
1547-
CreatesJoinRequest bool `json:"creates_join_request"`
1547+
CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
15481548
// IsPrimary is true, if the link is primary.
15491549
IsPrimary bool `json:"is_primary"`
15501550
// IsRevoked is true, if the link is revoked.
15511551
IsRevoked bool `json:"is_revoked"`
15521552
// Name is the name of the invite link.
15531553
//
15541554
// optional
1555-
Name string `json:"name"`
1555+
Name string `json:"name,omitempty"`
15561556
// ExpireDate is the point in time (Unix timestamp) when the link will
15571557
// expire or has been expired.
15581558
//
15591559
// optional
1560-
ExpireDate int `json:"expire_date"`
1560+
ExpireDate int `json:"expire_date,omitempty"`
15611561
// MemberLimit is the maximum number of users that can be members of the
15621562
// chat simultaneously after joining the chat via this invite link; 1-99999.
15631563
//
15641564
// optional
1565-
MemberLimit int `json:"member_limit"`
1565+
MemberLimit int `json:"member_limit,omitempty"`
15661566
// PendingJoinRequestCount is the number of pending join requests created
15671567
// using this link.
15681568
//
15691569
// optional
1570-
PendingJoinRequestCount int `json:"pending_join_request_count"`
1570+
PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
15711571
}
15721572

15731573
type ChatAdministratorRights struct {
@@ -1605,7 +1605,7 @@ type ChatMember struct {
16051605
// in the chat is hidden
16061606
//
16071607
// optional
1608-
IsAnonymous bool `json:"is_anonymous"`
1608+
IsAnonymous bool `json:"is_anonymous,omitempty"`
16091609
// UntilDate restricted and kicked only.
16101610
// Date when restrictions will be lifted for this user;
16111611
// unix time.
@@ -1624,7 +1624,7 @@ type ChatMember struct {
16241624
// any other administrator privilege.
16251625
//
16261626
// optional
1627-
CanManageChat bool `json:"can_manage_chat"`
1627+
CanManageChat bool `json:"can_manage_chat,omitempty"`
16281628
// CanPostMessages administrators only.
16291629
// True, if the administrator can post in the channel;
16301630
// channels only.
@@ -1646,7 +1646,7 @@ type ChatMember struct {
16461646
// True, if the administrator can manage video chats.
16471647
//
16481648
// optional
1649-
CanManageVideoChats bool `json:"can_manage_video_chats"`
1649+
CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
16501650
// CanRestrictMembers administrators only.
16511651
// True, if the administrator can restrict, ban or unban chat members.
16521652
//
@@ -1732,7 +1732,7 @@ type ChatMemberUpdated struct {
17321732
// for joining by invite link events only.
17331733
//
17341734
// optional
1735-
InviteLink *ChatInviteLink `json:"invite_link"`
1735+
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
17361736
}
17371737

17381738
// ChatJoinRequest represents a join request sent to a chat.
@@ -1746,11 +1746,11 @@ type ChatJoinRequest struct {
17461746
// Bio of the user.
17471747
//
17481748
// optional
1749-
Bio string `json:"bio"`
1749+
Bio string `json:"bio,omitempty"`
17501750
// InviteLink is the link that was used by the user to send the join request.
17511751
//
17521752
// optional
1753-
InviteLink *ChatInviteLink `json:"invite_link"`
1753+
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
17541754
}
17551755

17561756
// ChatPermissions describes actions that a non-administrator user is
@@ -1881,7 +1881,7 @@ type BaseInputMedia struct {
18811881
// which can be specified instead of parse_mode
18821882
//
18831883
// optional
1884-
CaptionEntities []MessageEntity `json:"caption_entities"`
1884+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
18851885
}
18861886

18871887
// InputMediaPhoto is a photo to send as part of a media group.
@@ -2163,7 +2163,7 @@ type InlineQuery struct {
21632163
// unless the request was sent from a secret chat
21642164
//
21652165
// optional
2166-
ChatType string `json:"chat_type"`
2166+
ChatType string `json:"chat_type,omitempty"`
21672167
// Location sender location, only for bots that request user location.
21682168
//
21692169
// optional
@@ -2676,23 +2676,23 @@ type InlineQueryResultLocation struct {
26762676
// measured in meters; 0-1500
26772677
//
26782678
// optional
2679-
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
2679+
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
26802680
// LivePeriod is the period in seconds for which the location can be
26812681
// updated, should be between 60 and 86400.
26822682
//
26832683
// optional
2684-
LivePeriod int `json:"live_period"`
2684+
LivePeriod int `json:"live_period,omitempty"`
26852685
// Heading is for live locations, a direction in which the user is moving,
26862686
// in degrees. Must be between 1 and 360 if specified.
26872687
//
26882688
// optional
2689-
Heading int `json:"heading"`
2689+
Heading int `json:"heading,omitempty"`
26902690
// ProximityAlertRadius is for live locations, a maximum distance for
26912691
// proximity alerts about approaching another chat member, in meters. Must
26922692
// be between 1 and 100000 if specified.
26932693
//
26942694
// optional
2695-
ProximityAlertRadius int `json:"proximity_alert_radius"`
2695+
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
26962696
// ReplyMarkup inline keyboard attached to the message
26972697
//
26982698
// optional
@@ -2726,15 +2726,15 @@ type InlineQueryResultMPEG4GIF struct {
27262726
// Width video width
27272727
//
27282728
// optional
2729-
Width int `json:"mpeg4_width"`
2729+
Width int `json:"mpeg4_width,omitempty"`
27302730
// Height vVideo height
27312731
//
27322732
// optional
2733-
Height int `json:"mpeg4_height"`
2733+
Height int `json:"mpeg4_height,omitempty"`
27342734
// Duration video duration
27352735
//
27362736
// optional
2737-
Duration int `json:"mpeg4_duration"`
2737+
Duration int `json:"mpeg4_duration,omitempty"`
27382738
// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
27392739
ThumbURL string `json:"thumb_url"`
27402740
// Title for the result
@@ -2989,7 +2989,7 @@ type SentWebAppMessage struct {
29892989
// keyboard attached to the message.
29902990
//
29912991
// optional
2992-
InlineMessageID string `json:"inline_message_id"`
2992+
InlineMessageID string `json:"inline_message_id,omitempty"`
29932993
}
29942994

29952995
// InputTextMessageContent contains text for displaying
@@ -3025,7 +3025,7 @@ type InputLocationMessageContent struct {
30253025
// measured in meters; 0-1500
30263026
//
30273027
// optional
3028-
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
3028+
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
30293029
// LivePeriod is the period in seconds for which the location can be
30303030
// updated, should be between 60 and 86400
30313031
//
@@ -3035,13 +3035,13 @@ type InputLocationMessageContent struct {
30353035
// in degrees. Must be between 1 and 360 if specified.
30363036
//
30373037
// optional
3038-
Heading int `json:"heading"`
3038+
Heading int `json:"heading,omitempty"`
30393039
// ProximityAlertRadius is for live locations, a maximum distance for
30403040
// proximity alerts about approaching another chat member, in meters. Must
30413041
// be between 1 and 100000 if specified.
30423042
//
30433043
// optional
3044-
ProximityAlertRadius int `json:"proximity_alert_radius"`
3044+
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
30453045
}
30463046

30473047
// InputVenueMessageContent contains a venue for displaying
@@ -3066,11 +3066,11 @@ type InputVenueMessageContent struct {
30663066
// GooglePlaceID is the Google Places identifier of the venue
30673067
//
30683068
// optional
3069-
GooglePlaceID string `json:"google_place_id"`
3069+
GooglePlaceID string `json:"google_place_id,omitempty"`
30703070
// GooglePlaceType is the Google Places type of the venue
30713071
//
30723072
// optional
3073-
GooglePlaceType string `json:"google_place_type"`
3073+
GooglePlaceType string `json:"google_place_type,omitempty"`
30743074
}
30753075

30763076
// InputContactMessageContent contains a contact for displaying

0 commit comments

Comments
 (0)