diff options
author | Runxi Yu <me@runxiyu.org> | 2024-12-30 01:23:40 +0000 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2024-12-30 01:23:40 +0000 |
commit | dce03955174abe5ad83c01c930e3bf47fe39d8ce (patch) | |
tree | cf4cddc3f83bc6eb9efd5be959d349fa47606c84 /cmd_nick.go | |
parent | Reformat (diff) | |
download | meseircd-dce03955174abe5ad83c01c930e3bf47fe39d8ce.tar.gz meseircd-dce03955174abe5ad83c01c930e3bf47fe39d8ce.tar.zst meseircd-dce03955174abe5ad83c01c930e3bf47fe39d8ce.zip |
Revamp
Diffstat (limited to 'cmd_nick.go')
-rw-r--r-- | cmd_nick.go | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/cmd_nick.go b/cmd_nick.go deleted file mode 100644 index deff08b..0000000 --- a/cmd_nick.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "fmt" - - "git.sr.ht/~runxiyu/meseircd/meselog" -) - -func init() { - CommandHandlers["NICK"] = handleClientNick -} - -func handleClientNick(msg RMsg, client *Client) error { - if len(msg.Params) < 1 { - return client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "NICK", "Not enough parameters")) - } - already, exists := nickToClient.LoadOrStore(msg.Params[0], client) - if exists { - if already != client { - err := client.Send(MakeMsg(self, ERR_NICKNAMEINUSE, client.Nick, msg.Params[0], "Nickname is already in use")) - if err != nil { - return err - } - } - } else { - if (client.State >= ClientStateRegistered || client.Nick != "*") && !nickToClient.CompareAndDelete(client.Nick, client) { - meselog.Error("nick inconsistent", "nick", client.Nick, "client", client) - return fmt.Errorf("%w: %v", ErrInconsistentClient, client) - } - if client.State == ClientStateRegistered { - err := client.Send(MakeMsg(client, "NICK", msg.Params[0])) - if err != nil { - return err - } - } - client.Nick = msg.Params[0] - } - if client.State < ClientStateRegistered { - err := client.checkRegistration() - if err != nil { - return err - } - } - return nil -} |