removeWeeChatHead

Removes the WeeChat timestamp and nickname from the front of a string.

version(WithQuotePlugin)
private pure @safe
removeWeeChatHead
(
const string line
,
const string nickname
,
const string prefixes
)

Parameters

line string

Full string line as copy/pasted from WeeChat.

nickname string

The nickname to remove (along with the timestamp).

prefixes string

The available user prefixes on the current server.

Return Value

Type: auto

The original line with the WeeChat timestamp and nickname sliced away, or as it was passed. No new string is ever allocated.

Examples

immutable prefixes = "!~&@%+";

{
    enum line = "20:08:27 @zorael | dresing";
    immutable modified = removeWeeChatHead(line, "zorael", prefixes);
    assert((modified == "dresing"), modified);
}
{
    enum line = "               20:08:27                   @zorael | dresing";
    immutable modified = removeWeeChatHead(line, "zorael", prefixes);
    assert((modified == "dresing"), modified);
}
{
    enum line = "+zorael | dresing";
    immutable modified = removeWeeChatHead(line, "zorael", prefixes);
    assert((modified == "dresing"), modified);
}
{
    enum line = "2y:08:27 @zorael | dresing";
    immutable modified = removeWeeChatHead(line, "zorael", prefixes);
    assert((modified == line), modified);
}
{
    enum line = "16:08:27       <-- | kameloso (~kameloso@2001:41d0:2:80b4::) " ~
        "has quit (Remote host closed the connection)";
    immutable modified = removeWeeChatHead(line, "kameloso", prefixes);
    assert((modified == line), modified);
}