mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-15 20:15:11 +02:00
Enable setting network commands on network creation
This commit is contained in:
parent
9dbb6e5e19
commit
e4e57b00c0
|
@ -252,7 +252,18 @@
|
||||||
placeholder="The Lounge - https://thelounge.chat"
|
placeholder="The Lounge - https://thelounge.chat"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="defaults.uuid && !$store.state.serverConfiguration.public">
|
<template v-if="!defaults.uuid">
|
||||||
|
<div class="connect-row">
|
||||||
|
<label for="connect:channels">Channels</label>
|
||||||
|
<input
|
||||||
|
id="connect:channels"
|
||||||
|
v-model="defaults.join"
|
||||||
|
class="input"
|
||||||
|
name="join"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="!$store.state.serverConfiguration.public">
|
||||||
<div class="connect-row">
|
<div class="connect-row">
|
||||||
<label for="connect:commands">
|
<label for="connect:commands">
|
||||||
Commands
|
Commands
|
||||||
|
@ -260,7 +271,7 @@
|
||||||
class="tooltipped tooltipped-ne tooltipped-no-delay"
|
class="tooltipped tooltipped-ne tooltipped-no-delay"
|
||||||
aria-label="One /command per line.
|
aria-label="One /command per line.
|
||||||
Each command will be executed in
|
Each command will be executed in
|
||||||
the server tab on new connection"
|
the server tab on every connection."
|
||||||
>
|
>
|
||||||
<button class="extra-help" />
|
<button class="extra-help" />
|
||||||
</span>
|
</span>
|
||||||
|
@ -276,17 +287,6 @@ the server tab on new connection"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!defaults.uuid">
|
|
||||||
<div class="connect-row">
|
|
||||||
<label for="connect:channels">Channels</label>
|
|
||||||
<input
|
|
||||||
id="connect:channels"
|
|
||||||
v-model="defaults.join"
|
|
||||||
class="input"
|
|
||||||
name="join"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-if="$store.state.serverConfiguration.public">
|
<template v-if="$store.state.serverConfiguration.public">
|
||||||
<template v-if="config.lockNetwork">
|
<template v-if="config.lockNetwork">
|
||||||
|
|
|
@ -22,6 +22,18 @@ const fieldsForClient = {
|
||||||
serverOptions: true,
|
serverOptions: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const parseCommands = function (commands) {
|
||||||
|
if (!commands) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split commands into an array
|
||||||
|
return commands
|
||||||
|
.replace(/\r\n|\r|\n/g, "\n")
|
||||||
|
.split("\n")
|
||||||
|
.filter((command) => command.length > 0);
|
||||||
|
};
|
||||||
|
|
||||||
function Network(attr) {
|
function Network(attr) {
|
||||||
_.defaults(this, attr, {
|
_.defaults(this, attr, {
|
||||||
name: "",
|
name: "",
|
||||||
|
@ -83,6 +95,10 @@ function Network(attr) {
|
||||||
this.channels.every((chan) => chan.muted || chan.type === Chan.Type.SPECIAL),
|
this.channels.every((chan) => chan.muted || chan.type === Chan.Type.SPECIAL),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.commands && !Array.isArray(this.commands)) {
|
||||||
|
this.commands = parseCommands(this.commands);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Network.prototype.validate = function (client) {
|
Network.prototype.validate = function (client) {
|
||||||
|
@ -298,10 +314,7 @@ Network.prototype.edit = function (client, args) {
|
||||||
this.proxyEnabled = !!args.proxyEnabled;
|
this.proxyEnabled = !!args.proxyEnabled;
|
||||||
|
|
||||||
// Split commands into an array
|
// Split commands into an array
|
||||||
this.commands = String(args.commands || "")
|
this.commands = parseCommands(String(args.commands || ""));
|
||||||
.replace(/\r\n|\r|\n/g, "\n")
|
|
||||||
.split("\n")
|
|
||||||
.filter((command) => command.length > 0);
|
|
||||||
|
|
||||||
// Sync lobby channel name
|
// Sync lobby channel name
|
||||||
this.channels[0].name = this.name;
|
this.channels[0].name = this.name;
|
||||||
|
|
|
@ -395,9 +395,12 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
|
||||||
if (_.isPlainObject(data)) {
|
if (_.isPlainObject(data)) {
|
||||||
// prevent people from overriding webirc settings
|
// prevent people from overriding webirc settings
|
||||||
data.uuid = null;
|
data.uuid = null;
|
||||||
data.commands = null;
|
|
||||||
data.ignoreList = null;
|
data.ignoreList = null;
|
||||||
|
|
||||||
|
if (Helper.config.webirc !== null) {
|
||||||
|
data.commands = null;
|
||||||
|
}
|
||||||
|
|
||||||
client.connect(data);
|
client.connect(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue