v0.7.0; support for test server and local bot api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package laniakea
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -35,6 +36,8 @@ func generateBotCommandForPlugin(pl Plugin) []tgapi.BotCommand {
|
||||
return commands
|
||||
}
|
||||
|
||||
var ErrTooManyCommands = errors.New("too many commands. max 100")
|
||||
|
||||
func (b *Bot) AutoGenerateCommands() error {
|
||||
_, err := b.api.DeleteMyCommands(tgapi.DeleteMyCommandsP{})
|
||||
if err != nil {
|
||||
@@ -45,6 +48,9 @@ func (b *Bot) AutoGenerateCommands() error {
|
||||
for _, pl := range b.plugins {
|
||||
commands = append(commands, generateBotCommandForPlugin(pl)...)
|
||||
}
|
||||
if len(commands) > 100 {
|
||||
return ErrTooManyCommands
|
||||
}
|
||||
|
||||
privateChatsScope := &tgapi.BotCommandScope{Type: tgapi.BotCommandScopePrivateType}
|
||||
groupChatsScope := &tgapi.BotCommandScope{Type: tgapi.BotCommandScopeGroupType}
|
||||
|
||||
Reference in New Issue
Block a user