replaceTokens

Apply some common text replacements. Used on part and quit reasons.

  1. auto replaceTokens(string line, IRCClient client)
    @safe pure nothrow
    replaceTokens
    (
    const string line
    ,
    const IRCClient client
    )
  2. auto replaceTokens(string line)

Parameters

line string

String to replace tokens in.

client IRCClient

The current IRCClient.

Return Value

Type: auto

A modified string with token occurrences replaced.

Examples

import kameloso.constants : KamelosoInfo;
import std.format : format;

IRCClient client;
client.nickname = "harbl";

{
    immutable line = "asdf $nickname is kameloso version $version from $source";
    immutable expected = "asdf %s is kameloso version %s from %s"
        .format(client.nickname, cast(string)KamelosoInfo.version_,
            cast(string)KamelosoInfo.source);
    immutable actual = line.replaceTokens(client);
    assert((actual == expected), actual);
}
{
    immutable line = "";
    immutable expected = "";
    immutable actual = line.replaceTokens(client);
    assert((actual == expected), actual);
}
{
    immutable line = "blerp";
    immutable expected = "blerp";
    immutable actual = line.replaceTokens(client);
    assert((actual == expected), actual);
}

Meta