Do not panic if BouncerServ command without handler is sent

git-svn-id: file:///srv/svn/repo/suika/trunk@334 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
fox.cpp 2020-06-10 14:33:13 +00:00
parent 969469c37d
commit c3141986b1

View File

@ -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))
}