Skip to content

Commit 3b5c8a9

Browse files
committed
Add allowed_updates to GetUpdates
1 parent 24d4f79 commit 3b5c8a9

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

bot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func (bot *BotAPI) GetFile(config FileConfig) (File, error) {
387387
// GetUpdates fetches updates.
388388
// If a WebHook is set, this will not return any data!
389389
//
390-
// Offset, Limit, and Timeout are optional.
390+
// Offset, Limit, Timeout, and AllowedUpdates are optional.
391391
// To avoid stale items, set Offset to one higher than the previous item.
392392
// Set Timeout to a large number to reduce requests so you can get updates
393393
// instantly instead of having to wait between requests.

configs.go

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,54 @@ const (
4242
ModeHTML = "HTML"
4343
)
4444

45+
// Constant values for update types
46+
const (
47+
// New incoming message of any kind — text, photo, sticker, etc.
48+
UpdateTypeMessage = "message"
49+
50+
// New version of a message that is known to the bot and was edited
51+
UpdateTypeEditedMessage = "edited_message"
52+
53+
// New incoming channel post of any kind — text, photo, sticker, etc.
54+
UpdateTypeChannelPost = "channel_post"
55+
56+
// New version of a channel post that is known to the bot and was edited
57+
UpdateTypeEditedChannelPost = "edited_channel_post"
58+
59+
// New incoming inline query
60+
UpdateTypeInlineQuery = "inline_query"
61+
62+
// The result of an inline query that was chosen by a user and sent to their
63+
// chat partner. Please see the documentation on the feedback collecting for
64+
// details on how to enable these updates for your bot.
65+
UpdateTypeChosenInlineResult = "chosen_inline_result"
66+
67+
// New incoming callback query
68+
UpdateTypeCallbackQuery = "callback_query"
69+
70+
// New incoming shipping query. Only for invoices with flexible price
71+
UpdateTypeShippingQuery = "shipping_query"
72+
73+
// New incoming pre-checkout query. Contains full information about checkout
74+
UpdateTypePreCheckoutQuery = "pre_checkout_query"
75+
76+
// New poll state. Bots receive only updates about stopped polls and polls
77+
// which are sent by the bot
78+
UpdateTypePoll = "poll"
79+
80+
// A user changed their answer in a non-anonymous poll. Bots receive new votes
81+
// only in polls that were sent by the bot itself.
82+
UpdateTypePollAnswer = "poll_answer"
83+
84+
// The bot's chat member status was updated in a chat. For private chats, this
85+
// update is received only when the bot is blocked or unblocked by the user.
86+
UpdateTypeMyChatMember = "my_chat_member"
87+
88+
// The bot must be an administrator in the chat and must explicitly specify
89+
// this update in the list of allowed_updates to receive these updates.
90+
UpdateTypeChatMember = "chat_member"
91+
)
92+
4593
// Library errors
4694
const (
4795
// ErrBadFileType happens when you pass an unknown type
@@ -888,9 +936,10 @@ func (config FileConfig) params() (Params, error) {
888936

889937
// UpdateConfig contains information about a GetUpdates request.
890938
type UpdateConfig struct {
891-
Offset int
892-
Limit int
893-
Timeout int
939+
Offset int
940+
Limit int
941+
Timeout int
942+
AllowedUpdates []string
894943
}
895944

896945
func (UpdateConfig) method() string {
@@ -903,6 +952,7 @@ func (config UpdateConfig) params() (Params, error) {
903952
params.AddNonZero("offset", config.Offset)
904953
params.AddNonZero("limit", config.Limit)
905954
params.AddNonZero("timeout", config.Timeout)
955+
params.AddInterface("allowed_updates", config.AllowedUpdates)
906956

907957
return params, nil
908958
}

0 commit comments

Comments
 (0)