Use unique user in unknown command test to avoid last-command fallback interference. Add plugin architecture with registered commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
524 B
Go
27 lines
524 B
Go
package main
|
|
|
|
import "strings"
|
|
|
|
type Plugin interface {
|
|
Name() string
|
|
ShortHelp() string
|
|
DetailedHelp() string
|
|
Execute(msg BotMessage, args string) string
|
|
}
|
|
|
|
var registry = map[string]Plugin{}
|
|
|
|
func registerPlugin(p Plugin) {
|
|
registry[p.Name()] = p
|
|
}
|
|
|
|
func SplitFirstWord(input string) (firstWord string, restOfString string) {
|
|
words := strings.Fields(input)
|
|
if len(words) == 0 {
|
|
return "", ""
|
|
}
|
|
firstWord = words[0]
|
|
restOfString = strings.Join(words[1:], " ")
|
|
return strings.ToLower(firstWord), restOfString
|
|
}
|