Register commands with Telegram.

This commit is contained in:
Benjamin A. Shelton 2026-10-02 23:43:23 -06:00
commit a8a715dbaa
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -103,6 +103,7 @@ func NewBot() (bot *Bot, errch chan error, err error) {
}
bot.AttachHandlers()
bot.SetCommands(ctx)
return
}
@ -151,6 +152,47 @@ func (b *Bot) SendScripture() {
}*/
}
func (b *Bot) SetCommands(ctx context.Context) (err error) {
commands, err := b.Bot.GetMyCommands(ctx, &telego.GetMyCommandsParams{})
fmt.Println(commands)
if len(commands) > 0 {
return
}
b.Bot.SetMyCommands(ctx, &telego.SetMyCommandsParams{
Commands: []telego.BotCommand{
{
Command: "help",
Description: "Displays bot usage and help.",
IsEphemeral: true,
},
{
Command: "settings",
Description: "Bot settings.",
IsEphemeral: true,
},
{
Command: "start",
Description: "Starts the bot and links it to the current user's channel.",
IsEphemeral: true,
},
{
Command: "verse",
Description: "Looks up a Bible passage. Optionally accepts a translation identifier as its second argument.",
},
{
Command: "random",
Description: "Submits a random Bible passage to the current chat.",
},
{
Command: "add",
Description: "Submits a passage to the bot's daily passage rotation.",
IsEphemeral: true,
},
},
})
return
}
func (b *Bot) SetPolling(ctx context.Context, conf *settings.Settings) (err error) {
err = b.Bot.DeleteWebhook(ctx,
&telego.DeleteWebhookParams{