v0.7.0; support for test server and local bot api

This commit is contained in:
2026-02-19 11:49:04 +03:00
parent d84b0a1b55
commit 0e0f8a0813
4 changed files with 115 additions and 65 deletions

View File

@@ -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}