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
(
ref IRCClient client
,
ref IRCServer server
,)

Parameters

client IRCClient

Reference to the IRCClient to complete.

server IRCServer

Reference to the IRCServer to complete.

bot IRCBot

Reference to the IRCBot to complete.

Examples

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

IRCClient client;
IRCServer server;
IRCBot bot;

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(client, server, bot);

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((bot.quitReason == KamelosoDefaults.quitReason), bot.quitReason);
assert((bot.partReason == KamelosoDefaults.partReason), bot.partReason);

client.nickname = string.init;
applyDefaults(client, server, bot);

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

Meta