Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
0.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Skhmt committed Mar 14, 2016
1 parent e3507f6 commit 8f15ed3
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 75 deletions.
14 changes: 13 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,19 @@
<div class="col-sm-12">
<div class="panel panel-default" id="commandsConfigPanel">
<div class="panel-body">
Command Symbol: !
<form class="form-inline" onsubmit="return false;">
<label class="control-label">Command Symbol: </label>&nbsp;
<input type="text" id="commandSymbolField" class="form-control input-sm" size="1">
</form>
<form class="form-inline" onsubmit="return false;">
<label class="control-label">Timeout for user commands: </label>&nbsp;
<div class="form-group">
<div class="input-group input-group-sm">
<input type="text" id="commandTimeoutField" class="form-control" size="1">
<span class="input-group-addon">s</span>
</div>
</div>
</form>
</div>
</div>
</div>
Expand Down
54 changes: 53 additions & 1 deletion src/js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
var cmdSettings = {};
var lap;
var cmdList = [];
var cmdTimeoutList = [];

function cmdSetup() {

Expand Down Expand Up @@ -53,6 +54,7 @@ function cmdSetup() {
custom : [], //{name, userType, text}
quotes: [],
uptime: "bot",
timeout: 3,
songRequests: true
};
}
Expand Down Expand Up @@ -83,6 +85,37 @@ function cmdSetup() {
cmdSettings.uptime = this.value;
} );

$('#commandSymbolField').val( cmdSettings.symbol );
$('#commandSymbolField').on( 'input', function() {
if ( this.value.length == 1 ) {
cmdSettings.symbol = this.value;
}
else if ( this.value.length > 1 ) {
this.value = this.value.length.charAt(0);
}
} );


if ( !cmdSettings.timeout ) {
$('#commandTimeoutField').val( 0 );
cmdSettings.timeout = 0;
}
else {
$('#commandTimeoutField').val( cmdSettings.timeout );
}
$('#commandTimeoutField').on( 'input', function() {
if ( this.value == parseInt(this.value) ) {
cmdSettings.timeout = this.value;
}
else if ( this.value < 0 ) {
cmdSettings.timeout = 0;
this.value = 0;
}
else {
cmdSettings.timeout = 0;
this.value = 0;
}
} );

addStaticCommands();

Expand All @@ -99,6 +132,12 @@ function cmdSetup() {
function parseCommand(text, from, mod, subscriber) {

if (!commandsOn) return;

if ( cmdTimeoutList.indexOf(from) > -1 ) {
log( `${from} is on command cooldown` );
return;
}

// there is an array cmdList: [ {cmd: "", func: ""}, ... ]
// it has been constructed of static and custom commands
// it can be added to by plugins
Expand All @@ -121,7 +160,7 @@ function parseCommand(text, from, mod, subscriber) {
if ( rbac == "bot" ) return;
}
eval(`${cmdList[i].func}(${JSON.stringify(params)}, "${from}", ${mod}, ${subscriber})`);
return;
return addToCommandTimeout(from);
}
}

Expand All @@ -131,6 +170,19 @@ function parseCommand(text, from, mod, subscriber) {
} else {
customCommand( cmd, params, from, mod, subscriber);
}
addToCommandTimeout(from);

}

function addToCommandTimeout(from) {
if ( cmdSettings.timeout > 0 ) {
console.log('added ' + from + ' to cmdTimeoutList');
cmdTimeoutList.push(from);
setTimeout( function() {
cmdTimeoutList.splice( cmdTimeoutList.indexOf(from), 1 );
console.log('removed ' + from + ' to cmdTimeoutList');
}, cmdSettings.timeout * 1000 );
}
}

function refreshCommands() {
Expand Down
24 changes: 12 additions & 12 deletions src/js/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,69 +127,69 @@ function moderationSetup(){
// wordProArea settings
$("#wordProArea").val( modSettings.wordPro.badwords.join(" ") );
$("#wordProArea").change( function() {
modSettings.wordPro.badwords = $(this).val().split(" ");
modSettings.wordPro.badwords = this.value.split(" ");
} );

// set up timeout states and listeners
$("#linkProTimeoutField").val( modSettings.linkPro.timeout );
$("#linkProTimeoutField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.linkPro.timeout = parseInt( tempNum, 10 );
} );

$("#linkProTimeoutText").val( modSettings.linkPro.timeoutText );
$("#linkProTimeoutText").on( "input", function() {
modSettings.linkPro.timeoutText = $(this).val();
modSettings.linkPro.timeoutText = this.value;
} );

$("#wordProTimeoutField").val( modSettings.wordPro.timeout );
$("#wordProTimeoutField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.wordPro.timeout = parseInt( tempNum, 10 );
} );

$("#wordProTimeoutText").val( modSettings.wordPro.timeoutText );
$("#wordProTimeoutText").on( "input", function() {
modSettings.wordPro.timeoutText = $(this).val();
modSettings.wordPro.timeoutText = this.value;
} );

$("#capsProTimeoutField").val( modSettings.capsPro.timeout );
$("#capsProTimeoutField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.capsPro.timeout = parseInt( tempNum, 10 );
} );

$("#capsProTimeoutText").val( modSettings.capsPro.timeoutText );
$("#capsProTimeoutText").on( "input", function() {
modSettings.capsPro.timeoutText = $(this).val();
modSettings.capsPro.timeoutText = this.value;
} );

$("#capsProPerWordField").val( modSettings.capsPro.capsPerWord );
$("#capsProPerWordField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.capsPro.capsPerWord = parseInt( tempNum, 10 );
} );

$("#capsProPerPostField").val( modSettings.capsPro.capsTotal );
$("#capsProPerPostField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.capsPro.capsTotal = parseInt( tempNum, 10 );
} );

$("#symbolProTimeoutField").val( modSettings.symbolPro.timeout );
$("#symbolProTimeoutField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.symbolPro.timeout = parseInt( tempNum, 10 );
} );

$("#symbolProTimeoutText").val( modSettings.symbolPro.timeoutText );
$("#symbolProTimeoutText").on( "input", function() {
modSettings.symbolPro.timeoutText = $(this).val();
modSettings.symbolPro.timeoutText = this.value;
} );

$("#symbolProSymbolsField").val( modSettings.symbolPro.symbols );
$("#symbolProSymbolsField").on( "input", function() {
var tempNum = $(this).val();
var tempNum = this.value;
modSettings.symbolPro.symbols = parseInt( tempNum, 10 );
} );

Expand Down
Loading

0 comments on commit 8f15ed3

Please sign in to comment.