applyDefaults

Completes a client's, server's and bot's member fields. Empty members are given values from compile-time defaults.

Nickname, user, GECOS/"real name", server address and server port are required. If there is no nickname, generate a random one. For any other empty values, update them with relevant such from KamelosoDefaults (and KamelosoDefaultIntegers).

@safe
void
applyDefaults

Parameters

instance Kameloso

The current Kameloso instance.

Examples

import kameloso.constants : KamelosoDefaults, KamelosoDefaultIntegers;
import std.conv : to;

auto instance = new Kameloso;

with (instance.parser)
{
    assert(!client.nickname.length, client.nickname);
    assert(!client.user.length, client.user);
    assert(!client.ident.length, client.ident);
    assert(!client.realName.length, client.realName);
    assert(!server.address, server.address);
    assert((server.port == 0), server.port.to!string);

    applyDefaults(instance);

    assert(client.nickname.length);
    assert((client.user == KamelosoDefaults.user), client.user);
    assert(!client.ident.length, client.ident);
    assert((client.realName == KamelosoDefaults.realName), client.realName);
    assert((server.address == KamelosoDefaults.serverAddress), server.address);
    assert((server.port == KamelosoDefaultIntegers.port), server.port.to!string);
    assert((instance.bot.quitReason == KamelosoDefaults.quitReason), instance.bot.quitReason);
    assert((instance.bot.partReason == KamelosoDefaults.partReason), instance.bot.partReason);

    client.nickname = string.init;
    applyDefaults(instance);

    assert(client.nickname.length, client.nickname);
}