Do not panic if BouncerServ command without handler is sent

This commit is contained in:
fox.cpp 2020-06-09 14:39:28 +03:00 committed by Simon Ser
parent 1cbdb26dd1
commit ce37fcc7c2
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -76,6 +76,20 @@ func handleServicePRIVMSG(dc *downstreamConn, text string) {
return 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 { if err := cmd.handle(dc, params); err != nil {
sendServicePRIVMSG(dc, fmt.Sprintf("error: %v", err)) sendServicePRIVMSG(dc, fmt.Sprintf("error: %v", err))
} }