mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-10 18:38:11 -07:00
commands: Simplify and unify minimum required number of args handling
This commit is contained in:
@@ -64,6 +64,14 @@ func NewServer(config *Config) *Server {
|
||||
theaters: config.Theaters(),
|
||||
}
|
||||
|
||||
// ensure that there is a minimum number of args specified for every command
|
||||
for name, _ := range parseCommandFuncs {
|
||||
_, exists := commandMinimumArgs[name]
|
||||
if !exists {
|
||||
log.Fatal("commandMinArgs not found for ", name)
|
||||
}
|
||||
}
|
||||
|
||||
if config.Server.MOTD != "" {
|
||||
file, err := os.Open(config.Server.MOTD)
|
||||
if err == nil {
|
||||
@@ -162,6 +170,12 @@ func (server *Server) loadChannels() {
|
||||
func (server *Server) processCommand(cmd Command) {
|
||||
client := cmd.Client()
|
||||
|
||||
numCmd, ok := cmd.(*NeedMoreParamsCommand)
|
||||
if ok {
|
||||
client.ErrNeedMoreParams(numCmd.code)
|
||||
return
|
||||
}
|
||||
|
||||
if !client.registered {
|
||||
regCmd, ok := cmd.(RegServerCommand)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user