A modified string with token occurrences replaced.
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); }
Apply some common text replacements. Used on part and quit reasons.