Changeset 334 in code for trunk/service.go


Ignore:
Timestamp:
Jun 10, 2020, 2:33:13 PM (5 years ago)
Author:
fox.cpp
Message:

Do not panic if BouncerServ command without handler is sent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/service.go

    r333 r334  
    7777        }
    7878
     79        if cmd.handle == nil {
     80                if len(cmd.children) > 0 {
     81                        var l []string
     82                        appendServiceCommandSetHelp(cmd.children, words, &l)
     83                        sendServicePRIVMSG(dc, "available commands: "+strings.Join(l, ", "))
     84                } else {
     85                        // Pretend the command does not exist if it has neither children nor handler.
     86                        // This is obviously a bug but it is better to not die anyway.
     87                        dc.logger.Printf("command without handler and subcommands invoked:", words[0])
     88                        sendServicePRIVMSG(dc, fmt.Sprintf("command %q not found", words[0]))
     89                }
     90                return
     91        }
     92
    7993        if err := cmd.handle(dc, params); err != nil {
    8094                sendServicePRIVMSG(dc, fmt.Sprintf("error: %v", err))
Note: See TracChangeset for help on using the changeset viewer.