aboutsummaryrefslogblamecommitdiff
path: root/cmd_user.go
blob: 4c4c86af251187fec5d16884ed8c9d32947b632d (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                  
                                                       
                                
                                                                                                      
         
                             


                                                  



                                                 
                                   



                                                                                                               
                               
         
                  
 
package main

import (
// "log/slog"
)

func init() {
	commandHandlers["USER"] = handleClientUser
}

func handleClientUser(msg RMsg, client *Client) error {
	if len(msg.Params) < 4 {
		return client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "USER", "Not enough parameters"))
	}
	switch client.State {
	case ClientStatePreRegistration:
		client.Ident = "~" + msg.Params[0]
		client.Gecos = msg.Params[3]
		err := client.checkRegistration()
		if err != nil {
			return err
		}
	case ClientStateRegistered:
		err := client.Send(MakeMsg(self, ERR_ALREADYREGISTERED, client.Nick, "You may not reregister"))
		if err != nil {
			return err
		}
	case ClientStateRemote:
	}
	return nil
}