Fix handling empty commands

This commit is contained in:
Tulir Asokan 2020-12-28 00:21:17 +02:00
parent 48d7ec6919
commit eba66693b0

View file

@ -80,6 +80,9 @@ func (ce *CommandEvent) Reply(msg string, args ...interface{}) {
// Handle handles messages to the bridge // Handle handles messages to the bridge
func (handler *CommandHandler) Handle(roomID id.RoomID, user *User, message string) { func (handler *CommandHandler) Handle(roomID id.RoomID, user *User, message string) {
args := strings.Fields(message) args := strings.Fields(message)
if len(args) == 0 {
args = []string{"unknown-command"}
}
ce := &CommandEvent{ ce := &CommandEvent{
Bot: handler.bridge.Bot, Bot: handler.bridge.Bot,
Bridge: handler.bridge, Bridge: handler.bridge,
@ -162,7 +165,7 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
handler.CommandCreate(ce) handler.CommandCreate(ce)
} }
default: default:
ce.Reply("Unknown Command") ce.Reply("Unknown command, use the `help` command for help.")
} }
} }