mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Add aliases for animal command
This commit is contained in:
parent
fa6bf5ddb8
commit
b727751f31
1 changed files with 68 additions and 6 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Fluffy-Bean/lynxie/app"
|
||||
|
@ -22,9 +23,66 @@ func RegisterTinyfoxCommands(a *app.App) {
|
|||
}
|
||||
|
||||
var animals = []string{
|
||||
"fox", "yeen", "dog", "guara", "serval", "ott", "jackal", "bleat", "woof", "chi", "puma", "skunk", "tig", "wah",
|
||||
"manul", "snep", "jaguar", "badger", "chee", "racc", "bear", "capy", "bun", "marten", "caracal", "snek",
|
||||
"shiba", "dook", "leo", "yote", "poss", "chee", "lynx",
|
||||
"fox",
|
||||
"yeen",
|
||||
"dog",
|
||||
"guara",
|
||||
"serval",
|
||||
"ott",
|
||||
"jackal",
|
||||
"bleat",
|
||||
"woof",
|
||||
"chi",
|
||||
"puma",
|
||||
"skunk",
|
||||
"tig",
|
||||
"wah",
|
||||
"manul",
|
||||
"snep",
|
||||
"jaguar",
|
||||
"badger",
|
||||
"chee",
|
||||
"racc",
|
||||
"bear",
|
||||
"capy",
|
||||
"bun",
|
||||
"marten",
|
||||
"caracal",
|
||||
"snek",
|
||||
"shiba",
|
||||
"dook",
|
||||
"leo",
|
||||
"yote",
|
||||
"poss",
|
||||
"lynx",
|
||||
}
|
||||
|
||||
var animalAliases = map[string]string{
|
||||
"hyena": "yeen",
|
||||
"serv": "serval",
|
||||
"otter": "ott",
|
||||
"deer": "bleat",
|
||||
"wolf": "woof",
|
||||
"tiger": "tig",
|
||||
"red-panda": "wah",
|
||||
"panda": "wah",
|
||||
"manual": "manul",
|
||||
"palas": "manul",
|
||||
"palas-cat": "manul",
|
||||
"snow-leopard": "snep",
|
||||
"jag": "jaguar",
|
||||
"cheetah": "chee",
|
||||
"raccoon": "racc",
|
||||
"rac": "racc",
|
||||
"capybara": "capy",
|
||||
"bunny": "bun",
|
||||
"carac": "caracal",
|
||||
"snake": "snek",
|
||||
"ferret": "dook",
|
||||
"leopard": "leo",
|
||||
"coyote": "yote",
|
||||
"possum": "poss",
|
||||
"opossum": "poss",
|
||||
}
|
||||
|
||||
func registerAnimal(a *app.App) app.Callback {
|
||||
|
@ -46,10 +104,14 @@ func registerAnimal(a *app.App) app.Callback {
|
|||
}
|
||||
}
|
||||
if !slices.Contains(animals, options.Kind) {
|
||||
return app.Error{
|
||||
Msg: fmt.Sprintf("Animal %s is invalid", options.Kind),
|
||||
Err: errors.New("entered invalid animal name"),
|
||||
alias, ok := animalAliases[options.Kind]
|
||||
if !ok {
|
||||
return app.Error{
|
||||
Msg: fmt.Sprintf("Animal \"%s\" is invalid. The following animals are supported:\n%s", options.Kind, strings.Join(animals, ", ")),
|
||||
Err: errors.New("entered invalid animal name"),
|
||||
}
|
||||
}
|
||||
options.Kind = alias
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, "https://api.tinyfox.dev/img?animal="+options.Kind, nil)
|
||||
|
|
Loading…
Add table
Reference in a new issue