l10n and cmd generator WIP

This commit is contained in:
2026-02-17 22:44:23 +03:00
parent 4527dd661a
commit bb51a0ecb1
4 changed files with 149 additions and 67 deletions

26
cmd_generator.go Normal file
View File

@@ -0,0 +1,26 @@
package laniakea
import "git.nix13.pw/scuroneko/laniakea/tgapi"
func generateBotCommand(cmd Command) tgapi.BotCommand {
return tgapi.BotCommand{
Command: cmd.command, Description: cmd.command,
}
}
func generateBotCommandForPlugin(pl Plugin) []tgapi.BotCommand {
cmds := make([]tgapi.BotCommand, 0)
for _, cmd := range pl.Commands {
cmds = append(cmds, generateBotCommand(cmd))
}
return cmds
}
func (b *Bot) AutoGenerateCommands() error {
commands := make([]tgapi.BotCommand, 0)
for _, pl := range b.plugins {
commands = append(commands, generateBotCommandForPlugin(pl)...)
}
_, err := b.api.SetMyCommands(tgapi.SetMyCommandsP{Commands: commands})
return err
}