Add config option to generate random nickname

Closes: https://todo.sr.ht/~emersion/gamja/136
This commit is contained in:
Simon Ser 2022-09-12 13:04:59 +02:00
parent 34d3bd6df9
commit 54e1fc93d9
2 changed files with 10 additions and 1 deletions

View file

@ -106,7 +106,8 @@ gamja default settings can be set using a `config.json` file at the root:
// require it, "disabled" to never ask for a password, or "external" to
// use SASL EXTERNAL. Defaults to "optional".
"auth": "optional",
// Default nickname (string).
// Default nickname (string). If it contains a "*" character, it will
// be replaced with a random string.
"nick": "asdf",
// Don't display the login UI, immediately connect to the server
// (boolean).

View file

@ -323,6 +323,14 @@ export default class App extends Component {
this.config = config;
if (!connectParams.nick && connectParams.autoconnect) {
connectParams.nick = "user-*";
}
if (connectParams.nick && connectParams.nick.includes("*")) {
let placeholder = Math.random().toString(36).substr(2, 7);
connectParams.nick = connectParams.nick.replace("*", placeholder);
}
if (autojoin.length > 0) {
if (connectParams.autoconnect) {
// Ask the user whether they want to join that new channel.