mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-15 12:15:05 +00:00
fix(commands): remove examples from command discovery
This commit is contained in:
1 parent
b5c7427520
commit
a211b7f8b7
22 files changed
+47
-154
No files matched your search
@@ -29,25 +29,6 @@ func validateCommand(c Command) error {
|
||||
if strings.ContainsAny(c.Parameters, "\r\n") {
|
||||
return fmt.Errorf("command %q: parameters must be single-line", c.Name)
|
||||
}
|
||||
if strings.ContainsAny(c.Example, "\r\n") {
|
||||
return fmt.Errorf("command %q: example must be single-line", c.Name)
|
||||
}
|
||||
parameters := strings.TrimSpace(c.Parameters)
|
||||
example := strings.TrimSpace(c.Example)
|
||||
if c.Visibility == VisibilityPublic {
|
||||
if parameters == "" && example != "" {
|
||||
return fmt.Errorf("command %q: example requires parameters", c.Name)
|
||||
}
|
||||
if parameters != "" && example == "" {
|
||||
return fmt.Errorf("command %q: example is required when parameters are present", c.Name)
|
||||
}
|
||||
}
|
||||
if example != "" {
|
||||
prefix := "/" + c.Name
|
||||
if example != prefix && !strings.HasPrefix(example, prefix+" ") {
|
||||
return fmt.Errorf("command %q: example must invoke %s", c.Name, prefix)
|
||||
}
|
||||
}
|
||||
if c.Visibility == VisibilityPublic && utf8.RuneCountInString(c.TelegramMenuDescription()) > telegramCommandDescriptionMaxRunes {
|
||||
return fmt.Errorf("command %q: Telegram menu description exceeds %d characters", c.Name, telegramCommandDescriptionMaxRunes)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user