diff --git a/irc/commands.go b/irc/commands.go index c3d19cff..08e3ac1b 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -18,6 +18,7 @@ var ( NotEnoughArgsError = errors.New("not enough arguments") ErrParseCommand = errors.New("failed to parse message") parseCommandFuncs = map[string]parseCommandFunc{ + "CAP": NewCapCommand, "JOIN": NewJoinCommand, "MODE": NewModeCommand, "NICK": NewNickCommand, @@ -564,3 +565,19 @@ func NewOperCommand(args []string) (editableCommand, error) { password: args[1], }, nil } + +// TODO +type CapCommand struct { + BaseCommand + args []string +} + +func (msg *CapCommand) String() string { + return fmt.Sprintf("CAP(args=%s)", msg.args) +} + +func NewCapCommand(args []string) (editableCommand, error) { + return &CapCommand{ + args: args, + }, nil +} diff --git a/irc/server.go b/irc/server.go index 4e1cde15..6ab087b6 100644 --- a/irc/server.go +++ b/irc/server.go @@ -58,10 +58,14 @@ func (server *Server) receiveCommands(commands <-chan Command) { if server.password == "" { client.serverPass = true - } else if _, ok := command.(*PassCommand); !ok { - client.Reply(ErrPasswdMismatch(server)) - client.Destroy() - return + } else { + switch command.(type) { + case *PassCommand, *CapCommand: + default: + client.Reply(ErrPasswdMismatch(server)) + client.Destroy() + return + } } } command.HandleServer(server) @@ -393,3 +397,7 @@ func (msg *OperCommand) HandleServer(server *Server) { client.Reply(RplYoureOper(server)) client.Reply(RplUModeIs(server, client)) } + +func (msg *CapCommand) HandleServer(server *Server) { + // TODO +}