From eba66693b0e190874f6cfbe605d6424ea43fdd32 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 28 Dec 2020 00:21:17 +0200 Subject: [PATCH] Fix handling empty commands --- commands.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 4bb8293..8a7c058 100644 --- a/commands.go +++ b/commands.go @@ -80,6 +80,9 @@ func (ce *CommandEvent) Reply(msg string, args ...interface{}) { // Handle handles messages to the bridge func (handler *CommandHandler) Handle(roomID id.RoomID, user *User, message string) { args := strings.Fields(message) + if len(args) == 0 { + args = []string{"unknown-command"} + } ce := &CommandEvent{ Bot: handler.bridge.Bot, Bridge: handler.bridge, @@ -162,7 +165,7 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) { handler.CommandCreate(ce) } default: - ce.Reply("Unknown Command") + ce.Reply("Unknown command, use the `help` command for help.") } }