mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Implement /set command.
This commit is contained in:
parent
cca19444d6
commit
667412e6ae
3 changed files with 60 additions and 2 deletions
3
README
3
README
|
@ -109,6 +109,9 @@ to all users:
|
||||||
|
|
||||||
- `/me text`: sends a chat message starting with the sender's username;
|
- `/me text`: sends a chat message starting with the sender's username;
|
||||||
- `/leave`: equivalent to clicking the *Disconnect* button.
|
- `/leave`: equivalent to clicking the *Disconnect* button.
|
||||||
|
- `/set var val`: sets the value of a configuration variable without any
|
||||||
|
error checking. Without parameters, displays the current configuration.
|
||||||
|
- `/unset var`: removes a configuration variable.
|
||||||
|
|
||||||
The following commands are only available to users with operator
|
The following commands are only available to users with operator
|
||||||
privileges:
|
privileges:
|
||||||
|
|
|
@ -297,6 +297,11 @@ textarea.form-reply {
|
||||||
background: #ececec;
|
background: #ececec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-system {
|
||||||
|
font-size: 10px;
|
||||||
|
background: #ececec;
|
||||||
|
}
|
||||||
|
|
||||||
.message-row:after, .message-row:before {
|
.message-row:after, .message-row:before {
|
||||||
display: table;
|
display: table;
|
||||||
content: " ";
|
content: " ";
|
||||||
|
|
|
@ -126,6 +126,27 @@ function updateSettings(settings) {
|
||||||
storeSettings(s);
|
storeSettings(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} key
|
||||||
|
* @param {any} value
|
||||||
|
*/
|
||||||
|
function updateSetting(key, value) {
|
||||||
|
let s = {};
|
||||||
|
s[key] = value;
|
||||||
|
updateSettings(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} key
|
||||||
|
*/
|
||||||
|
function delSetting(key) {
|
||||||
|
let s = getSettings();
|
||||||
|
if(!(key in s))
|
||||||
|
return;
|
||||||
|
delete(s[key]);
|
||||||
|
storeSettings(s)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
*/
|
*/
|
||||||
|
@ -1209,7 +1230,9 @@ function addToChatbox(peerId, nick, kind, message){
|
||||||
let container = document.createElement('div');
|
let container = document.createElement('div');
|
||||||
container.classList.add('message');
|
container.classList.add('message');
|
||||||
row.appendChild(container);
|
row.appendChild(container);
|
||||||
if (userpass.username === nick) {
|
if(!peerId)
|
||||||
|
container.classList.add('message-system');
|
||||||
|
else if(userpass.username === nick) {
|
||||||
container.classList.add('message-sender');
|
container.classList.add('message-sender');
|
||||||
}
|
}
|
||||||
if(kind !== 'me') {
|
if(kind !== 'me') {
|
||||||
|
@ -1333,6 +1356,33 @@ function handleInput() {
|
||||||
}
|
}
|
||||||
serverConnection.groupAction('clearchat');
|
serverConnection.groupAction('clearchat');
|
||||||
return;
|
return;
|
||||||
|
case '/set':
|
||||||
|
if(!rest) {
|
||||||
|
let settings = getSettings();
|
||||||
|
let s = "";
|
||||||
|
for(let key in settings)
|
||||||
|
s = s + `${key}: ${JSON.stringify(settings[key])}\n`
|
||||||
|
addToChatbox(null, null, null, s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let parsed = parseCommand(rest);
|
||||||
|
let value;
|
||||||
|
if(parsed[1]) {
|
||||||
|
try {
|
||||||
|
value = JSON.parse(parsed[1])
|
||||||
|
} catch(e) {
|
||||||
|
displayError(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = true;
|
||||||
|
}
|
||||||
|
updateSetting(parsed[0], value);
|
||||||
|
reflectSettings();
|
||||||
|
return;
|
||||||
|
case '/unset':
|
||||||
|
delSetting(rest.trim());
|
||||||
|
return;
|
||||||
case '/lock':
|
case '/lock':
|
||||||
case '/unlock':
|
case '/unlock':
|
||||||
if(!serverConnection.permissions.op) {
|
if(!serverConnection.permissions.op) {
|
||||||
|
|
Loading…
Reference in a new issue