Merge pull request #2090 from thelounge/xpaw/rng-nick

Allow generating random numbers in nick on page load
This commit is contained in:
Jérémie Astori 2018-02-22 20:54:52 -05:00 committed by GitHub
commit a24ab74c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -236,18 +236,21 @@ module.exports = {
// //
// Nick // Nick
// //
// @type string // Percent sign (%) will be replaced into a random number from 0 to 9.
// @default "lounge-user" // For example, Guest%%% will become Guest123 on page load.
// //
nick: "lounge-user", // @type string
// @default "thelounge%%"
//
nick: "thelounge%%",
// //
// Username // Username
// //
// @type string // @type string
// @default "lounge-user" // @default "thelounge"
// //
username: "lounge-user", username: "thelounge",
// //
// Real Name // Real Name

View File

@ -517,7 +517,7 @@ function getClientConfiguration() {
config.themes = themes.getAll(); config.themes = themes.getAll();
if (config.displayNetwork) { if (config.displayNetwork) {
config.defaults = Helper.config.defaults; config.defaults = _.clone(Helper.config.defaults);
} else { } else {
// Only send defaults that are visible on the client // Only send defaults that are visible on the client
config.defaults = _.pick(Helper.config.defaults, [ config.defaults = _.pick(Helper.config.defaults, [
@ -529,6 +529,8 @@ function getClientConfiguration() {
]); ]);
} }
config.defaults.nick = config.defaults.nick.replace(/%/g, () => Math.floor(Math.random() * 10));
return config; return config;
} }