isValidChannel

Examines a string and judges whether or not it *looks* like a channel.

It needs to be passed an IRCServer to know the max channel name length. An alternative would be to change the IRCServer parameter to be an uint.

pure @safe
isValidChannel
(
const string channelName
,)

Parameters

channelName string

String of a potential channel name.

server IRCServer

The current IRCServer with all its settings.

Return Value

Type: auto

true if the string content is judged to be a channel, false if not.

Examples

IRCServer server;
assert("#channel".isValidChannel(server));
assert("##channel".isValidChannel(server));
assert(!"!channel".isValidChannel(server));
assert(!"#ch#annel".isValidChannel(server));
IRCServer s;
s.chantypes = "#&";

assert("#channelName".isValidChannel(s));
assert("&otherChannel".isValidChannel(s));
assert("##freenode".isValidChannel(s));
assert(!"###froonode".isValidChannel(s));
assert(!"#not a channel".isValidChannel(s));
assert(!"notAChannelEither".isValidChannel(s));
assert(!"#".isValidChannel(s));
//assert(!"".isValidChannel(s));
assert(!"##".isValidChannel(s));
assert(!"&&".isValidChannel(s));
assert("#d".isValidChannel(s));
assert("#uk".isValidChannel(s));
assert(!"###".isValidChannel(s));
assert(!"#a#".isValidChannel(s));
assert(!"a".isValidChannel(s));
assert(!" ".isValidChannel(s));
//assert(!"".isValidChannel(s));

version(TwitchSupport)
{
    s.daemon = IRCServer.Daemon.twitch;
    s.chantypes = "#";
    s.maxNickLength = 25;

    assert("#1oz".isValidChannel(s));
    assert(!"#åäö".isValidChannel(s));
    assert("#arunero9029".isValidChannel(s));
}