matchesByMask

Compares this IRCUser with a second one, treating fields with asterisks as glob wildcards, mimicking *!*@* mask matching.

pure @safe nothrow
matchesByMask

Parameters

this_ IRCUser

IRCUser to compare.

that IRCUser

IRCUser to compare this_ with.

caseMapping IRCServer.CaseMapping

IRCServer.CaseMapping

with which to translate the nicknames in the relevant masks to lowercase.

Return Value

Type: auto

true if the IRCUsers are deemed to match, false if not.

Examples

IRCServer server;

IRCUser u1;
with (u1)
{
    nickname = "foo";
    ident = "NaN";
    address = "asdf.asdf.com";
}

IRCUser u2;
with (u2)
{
    nickname = "*";
    ident = "NaN";
    address = "*";
}

assert(u1.matchesByMask(u2, server.caseMapping));
assert(u1.matchesByMask(IRCUser("f*!NaN@*.com"), server.caseMapping));
IRCUser first = IRCUser("kameloso!NaN@wopkfoewopk.com");

IRCUser second = IRCUser("*!*@*");
assert(first.matchesByMask(second));

IRCUser third = IRCUser("kame*!*@*.com");
assert(first.matchesByMask(third));

IRCUser fourth = IRCUser("*loso!*@wop*");
assert(first.matchesByMask(fourth));

assert(second.matchesByMask(first));
assert(third.matchesByMask(first));
assert(fourth.matchesByMask(first));

IRCUser fifth = IRCUser("kameloso!*@*");
IRCUser sixth = IRCUser("KAMELOSO!ident@address.com");
assert(fifth.matchesByMask(sixth));

IRCUser seventh = IRCUser("^[0V0]^!ID@ADD");
IRCUser eight = IRCUser("~{0v0}~!id@add");
assert(seventh.matchesByMask(eight, IRCServer.CaseMapping.rfc1459));
assert(!seventh.matchesByMask(eight, IRCServer.CaseMapping.strict_rfc1459));

IRCUser ninth = IRCUser("*!*@170.233.40.144]");  // Accidental trailing ]
IRCUser tenth = IRCUser("Joe!Shmoe@*");
assert(ninth.matchesByMask(tenth, IRCServer.CaseMapping.rfc1459));

IRCUser eleventh = IRCUser("abc]!*@*");
IRCUser twelfth = IRCUser("abc}!abc}@abc}");
assert(eleventh.matchesByMask(twelfth, IRCServer.CaseMapping.rfc1459));

Meta