lookup resolves the handler for an input: exact match first, then the ordered prefix routes. ok is false when nothing matches (chat/skill input).
(userInput string)
| 139 | // lookup resolves the handler for an input: exact match first, then the |
| 140 | // ordered prefix routes. ok is false when nothing matches (chat/skill input). |
| 141 | func (ch *CommandHandler) lookup(userInput string) (cmdFunc, bool) { |
| 142 | if fn, ok := ch.routes.exact[userInput]; ok { |
| 143 | return fn, true |
| 144 | } |
| 145 | for _, r := range ch.routes.prefixes { |
| 146 | if r.matches(userInput) { |
| 147 | return r.fn, true |
| 148 | } |
| 149 | } |
| 150 | return nil, false |
| 151 | } |
| 152 | |
| 153 | // handleDefault treats "/<name> [args]" as a manual skill invocation when |
| 154 | // <name> resolves to an installed user-invocable skill; otherwise it reports |