Register commands with Telegram.
This commit is contained in:
parent
273690e5fc
commit
a8a715dbaa
1 changed files with 42 additions and 0 deletions
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Reference in a new issue