Skip to content

Commit 1198abd

Browse files
committed
Avoid breaking change with GetMyCommands.
1 parent 66dc9e8 commit 1198abd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

bot.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,12 @@ func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error) {
667667
}
668668

669669
// GetMyCommands gets the currently registered commands.
670-
func (bot *BotAPI) GetMyCommands(config GetMyCommandsConfig) ([]BotCommand, error) {
670+
func (bot *BotAPI) GetMyCommands() ([]BotCommand, error) {
671+
return bot.GetMyCommandsWithConfig(GetMyCommandsConfig{})
672+
}
673+
674+
// GetMyCommandsWithConfig gets the currently registered commands with a config.
675+
func (bot *BotAPI) GetMyCommandsWithConfig(config GetMyCommandsConfig) ([]BotCommand, error) {
671676
resp, err := bot.Request(config)
672677
if err != nil {
673678
return nil, err

bot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ func TestCommands(t *testing.T) {
965965
t.Error("Unable to set commands")
966966
}
967967

968-
commands, err := bot.GetMyCommands(NewGetMyCommands())
968+
commands, err := bot.GetMyCommands()
969969
if err != nil {
970970
t.Error("Unable to get commands")
971971
}
@@ -987,7 +987,7 @@ func TestCommands(t *testing.T) {
987987
t.Error("Unable to set commands")
988988
}
989989

990-
commands, err = bot.GetMyCommands(NewGetMyCommandsWithScope(NewBotCommandScopeAllPrivateChats()))
990+
commands, err = bot.GetMyCommandsWithConfig(NewGetMyCommandsWithScope(NewBotCommandScopeAllPrivateChats()))
991991
if err != nil {
992992
t.Error("Unable to get commands")
993993
}

helpers.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,6 @@ func NewBotCommandScopeChatMember(chatID, userID int64) BotCommandScope {
888888
}
889889
}
890890

891-
// NewGetMyCommands allows you to set the registered commands.
892-
func NewGetMyCommands() GetMyCommandsConfig {
893-
return GetMyCommandsConfig{}
894-
}
895-
896891
// NewGetMyCommandsWithScope allows you to set the registered commands for a
897892
// given scope.
898893
func NewGetMyCommandsWithScope(scope BotCommandScope) GetMyCommandsConfig {

0 commit comments

Comments
 (0)