fix: correct Telegram update/keyboard models and harden env parsing

This commit is contained in:
2026-03-17 16:17:26 +03:00
parent 1e043da05d
commit 4ebe76dd4a
26 changed files with 992 additions and 140 deletions

View File

@@ -85,10 +85,10 @@ func LoadOptsFromEnv() *BotOpts {
}
}
stringUpdateTypes := strings.Split(os.Getenv("UPDATE_TYPES"), ";")
updateTypes := make([]tgapi.UpdateType, len(stringUpdateTypes))
for i, updateType := range stringUpdateTypes {
updateTypes[i] = tgapi.UpdateType(updateType)
stringUpdateTypes := splitEnvList(os.Getenv("UPDATE_TYPES"))
updateTypes := make([]tgapi.UpdateType, 0, len(stringUpdateTypes))
for _, updateType := range stringUpdateTypes {
updateTypes = append(updateTypes, tgapi.UpdateType(updateType))
}
return &BotOpts{
@@ -222,5 +222,25 @@ func LoadPrefixesFromEnv() []string {
if !exists {
return []string{"/"}
}
return strings.Split(prefixesS, ";")
prefixes := splitEnvList(prefixesS)
if len(prefixes) == 0 {
return []string{"/"}
}
return prefixes
}
func splitEnvList(value string) []string {
if value == "" {
return nil
}
parts := strings.Split(value, ";")
out := make([]string, 0, len(parts))
for _, part := range parts {
part = strings.TrimSpace(part)
if part == "" {
continue
}
out = append(out, part)
}
return out
}