telegram-bot-api icon indicating copy to clipboard operation
telegram-bot-api copied to clipboard

How to create main bot menu

Open dogonovm opened this issue 3 years ago • 5 comments

botMenu

How I can set bot menu. I can't find example.

Thank you!

dogonovm avatar May 18 '22 14:05 dogonovm

cfg := tgbotapi.NewSetMyCommands(
	tgbotapi.BotCommand{
		Command:     "/test",
		Description: "test command",
	},
)

_, _ = b.api.Request(cfg)

_, err = b.api.Request(tgbotapi.SetChatMenuButtonConfig{
	ChatID: {CHAT_ID},
	MenuButton: &tgbotapi.MenuButton{
		Type: "default",
	},
})

oanogin avatar Jun 12 '22 18:06 oanogin

Is it outdated?

mispon avatar Nov 15 '22 20:11 mispon

I'd like to know too )

code-by avatar Nov 24 '22 11:11 code-by

@code-by Yes, I suppose, I just registered my commands and got the menu button automatically

mispon avatar Nov 24 '22 15:11 mispon

here's how the updated code looks like.

...
	bot, err := tgbotapi.NewBotAPI(token)
	if err != nil {
		log.Panic(err)
	}
	cmdCfg := tgbotapi.NewSetMyCommands(
		tgbotapi.BotCommand{
			Command:     "start",
			Description: "start",
		},
		tgbotapi.BotCommand{
			Command:     "help",
			Description: "help",
		},
	)
	bot.Send(cmdCfg)
...

restart telegram app and it works

johnmerga avatar Jan 13 '24 17:01 johnmerga