From ce37fcc7c2488115264892cc147b31ce3114b14b Mon Sep 17 00:00:00 2001 From: "fox.cpp" Date: Tue, 9 Jun 2020 14:39:28 +0300 Subject: [PATCH] Do not panic if BouncerServ command without handler is sent --- service.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/service.go b/service.go index 85dfe19..e900338 100644 --- a/service.go +++ b/service.go @@ -76,6 +76,20 @@ func handleServicePRIVMSG(dc *downstreamConn, text string) { return } + if cmd.handle == nil { + if len(cmd.children) > 0 { + var l []string + appendServiceCommandSetHelp(cmd.children, words, &l) + sendServicePRIVMSG(dc, "available commands: "+strings.Join(l, ", ")) + } else { + // Pretend the command does not exist if it has neither children nor handler. + // This is obviously a bug but it is better to not die anyway. + dc.logger.Printf("command without handler and subcommands invoked:", words[0]) + sendServicePRIVMSG(dc, fmt.Sprintf("command %q not found", words[0])) + } + return + } + if err := cmd.handle(dc, params); err != nil { sendServicePRIVMSG(dc, fmt.Sprintf("error: %v", err)) }