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

Commit

Permalink
0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Skhmt committed Feb 25, 2016
1 parent d3d84e0 commit 8b0a8db
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 105 deletions.
59 changes: 36 additions & 23 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@
<!-- CHAT -->
<div class="tab-pane active" id="tab-chat">
<div class="row-fluid">
<div class="col-sm-9 col-md-10">
<div class="well well-sm scroll" id="console" style="height: calc(100vh - 125px);"></div>
<div class="col-sm-9 col-md-10" style="padding-right: 1px !important;">
<div class="well well-sm scroll" id="console" style="height: calc(100vh - 125px); margin-right: 0 !important;"></div>
</div>
<div class="col-sm-3 col-md-2">
<div class="well well-sm" id="viewercount" style="height: 60px; "></div>
<div class="well well-sm scroll" id="userlist" style="height: calc(100vh - 205px);"></div>
<div class="col-sm-3 col-md-2" style="padding-left: 1px !important;">
<div class="well well-sm" id="viewercount"
style="height: 60px; margin-left: 0 !important; margin-bottom: 1px !important;"></div>
<div class="well well-sm scroll" id="userlist"
style="height: calc(100vh - 187px); margin-left: 0 !important; margin-top: 2px !important;"></div>
</div>
</div>
<div class="row-fluid">
Expand Down Expand Up @@ -221,15 +223,9 @@
<span class="glyphicon glyphicon-step-forward"></span>
</button>
&nbsp; &nbsp;
<!-- <button id="volDownSongButton" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-volume-down"></span>
</button> -->
<button id="muteSongButton" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-volume-off"></span>
</button>
<!-- <button id="volUpSongButton" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-volume-up"></span>
</button> -->
&nbsp; &nbsp;
<div style="display:inline-block; width: 290px;" id="songVolumeContainer">
<div class="progress progress-striped active" style="margin-bottom: -5px !important;">
Expand Down Expand Up @@ -390,21 +386,29 @@
</td>
<td>
<form class="form-inline" onsubmit="return false;">
<label class="control-label">Add user:</label> &nbsp;
<input type="text" id="addUserPointsText" class="form-control input-sm" size="12">
<button class="btn btn-primary btn-sm" id="addUserPointsButton">
<span class="glyphicon glyphicon-plus"></span>
</button>
<label class="control-label">Add user:</label> &nbsp;
<input type="text" id="addUserPointsText" class="form-control input-sm" size="12">
<button class="btn btn-primary btn-sm" id="addUserPointsButton">
<span class="glyphicon glyphicon-plus"></span>
</button>
</form>
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" id="pointsListText" class="form-control input-sm" placeholder="Enter a username...">
</td>
<td>
<form class="form-inline" onsubmit="return false;">
<label class="control-label">Hours to Regular:</label> &nbsp;
<input type="text" id="regularPoints" class="form-control input-sm" size="4">
</form>
</td>
</tr>
</table>
<div class="panel-body">
<input type="text" id="pointsListText" class="form-control input-sm" placeholder="Enter a username...">
</div>
</div>

<div class="panel panel-default scroll" style="height: calc(100vh - 265px);" id="pointsList">
<div class="panel panel-default scroll" style="height: calc(100vh - 254px);" id="pointsList">
<table class="table table-striped table-hover">
<tr>
<th>Username</th>
Expand Down Expand Up @@ -435,7 +439,8 @@
<label class="control-label">Level:</label>&nbsp;
<select id="addCmdUserType" class="form-control input-sm">
<option value="">Any user</option>
<option value="sub">Only subs and mods</option>
<option value="reg">Regs, subs, and mods</option>
<option value="sub">Subs and mods</option>
<option value="mod">Only mods</option>
<option value="streamer">Only streamer</option>
</select>
Expand Down Expand Up @@ -794,14 +799,22 @@ <h1 class="panel-title">About </h1>
<div class="panel-body">
<p>
<em><a href="#" onclick="openLink('https://github.com/Skhmt/KoalaBot');">
https://github.com/Skhmt/KoalaBot
https://github.com/Skhmt/koalabot
</a></em><br>
<em><a href="#" onclick="openLink('https://www.reddit.com/r/koalabot');">
https://www.reddit.com/r/koalabot
</a></em>
</p>
<p>
Made by: skhmt, 2016.
Made by: <strong>skhmt</strong> (
<em><a href="#" onclick="openLink('https://twitter.com/SkTTV');">
twitter
</a></em>
|
<em><a href="#" onclick="openLink('http://www.twitch.tv/skhmt');">
twitch
</a></em>
), 2016.
</p>
<p>
Thanks to the people below that have helped a lot!
Expand Down
37 changes: 32 additions & 5 deletions src/js/commands-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ function addStaticCommands() {

var output = `<table class="table table-striped table-hover table-condensed">
<tr>
<th>Command</th>
<th>Access</th>
<th>Description</th>
<th class="col-sm-2">Command</th>
<th class="col-sm-3">Access</th>
<th class="col-sm-7">Description</th>
</tr>`;
for ( var i = 0; i < defaultCommands.length; i++ ) {
cmdList.push( {cmd: defaultCommands[i].cmd, func: defaultCommands[i].func, rbac: defaultCommands[i].rbac} );
var rbac = defaultCommands[i].rbac;
var cmd = defaultCommands[i].cmd;
output += `<tr>
<td>${cmdSettings.symbol}${defaultCommands[i].cmd}</td>
<td>${defaultCommands[i].rbac}</td>
<td>${cmdSettings.symbol}${cmd}</td>
<td>
<select class="form-control input-sm" id="cmdRBAC_${cmd}" onchange="changeRBAC('${cmd}')">
<option value="off" ${(rbac=='off')?'selected="selected"':''}>Off</option>
<option value="all" ${(rbac=='all')?'selected="selected"':''}>All users</option>
<option value="reg" ${(rbac=='reg')?'selected="selected"':''}>Regulars, Subs, Mods</option>
<option value="sub" ${(rbac=='sub')?'selected="selected"':''}>Subscribers & Mods</option>
<option value="mod" ${(rbac=='mod')?'selected="selected"':''}>Moderators</option>
<option value="bot" ${(rbac=='bot')?'selected="selected"':''}>Streamer (and bot) only</option>
</select>
</td>
<td>${defaultCommands[i].desc}</td>
</tr>`;
}
Expand All @@ -29,6 +40,22 @@ function addStaticCommands() {
$("#commandsConfigPanel").append(output);
}

function changeRBAC(cmd) {
var selector = `#cmdRBAC_${cmd}`;
var newRBAC = $(selector).val();

for (var i in defaultCommands) {
if ( defaultCommands[i].cmd == cmd ) {
defaultCommands[i].rbac = newRBAC;
}
}
for (var i in cmdList) {
if ( cmdList[i].cmd == cmd ) {
cmdList[i].rbac = newRBAC;
}
}
}

function createDefaultCommands() {

var cmds = [];
Expand Down
12 changes: 9 additions & 3 deletions src/js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function cmdAddCmd( params, from ) {
if ( params[0].substring(0,4) === "-ul=" ) {
var type = params[0].substring(4);
if ( type === "mod" ) tempCommand.userType = "mod";
else if ( type === "reg" ) tempCommand.userType = "reg";
else if ( type === "sub" ) tempCommand.userType = "sub";
else if ( type === "streamer" ) tempCommand.userType = "streamer";
params.splice(0,1); // removing !addcom -ul=*
Expand Down Expand Up @@ -274,14 +275,19 @@ function customCommand( cmd, params, from, mod, subscriber ) {
var isStreamer = ( from == settings.channel.substring(1) );
var isBot = ( from == settings.username );

var usertype = cmdSettings.custom[cmdIndex].userType;

// checking permissions
if ( cmdSettings.custom[cmdIndex].userType === "mod" && !mod && !isStreamer && !isBot ) {
if ( usertype === "mod" && !mod && !isStreamer && !isBot ) {
return;
}
else if ( usertype === "reg" && apiGetPoints(from) < pointsSettings.regularPoints && !mod && !subscriber && !isStreamer && !isBot ) {
return;
}
else if ( cmdSettings.custom[cmdIndex].userType === "sub" && !mod && !subscriber && !isStreamer && !isBot ) {
else if ( usertype === "sub" && !mod && !subscriber && !isStreamer && !isBot ) {
return;
}
else if ( cmdSettings.custom[cmdIndex].userType === "streamer" && !isStreamer && !isBot ) {
else if ( usertype === "streamer" && !isStreamer && !isBot ) {
return;
}

Expand Down
79 changes: 79 additions & 0 deletions src/js/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,82 @@ function apiHotkey(hotkey) {

return shortcut;
}


function apiDB(filename) {
if (!filename) return null;

var my = {};

my._db; // = new sql.Database();

my.write = function() {
try {
var binArray = my._db.export();
var buffer = new Buffer( binArray );
fs.writeFileSync( filename, buffer );
return true;
} catch (err) {
console.log(err);
return false;
}
};

my.sel = function(query) {
try {
var response = my._db.exec(query);
return {array: response, table: tableify(response)};
} catch(err) {
console.log(err);
return null;
}
};

// CREATE TABLE / INSERT INTO / DELETE FROM
my.run = function(query) {
try {
my._db.run(query);
return true;
} catch(err) {
console.log(err);
return false;
}
};

try {
var file = fs.readFileSync( filename );
my._db = new sql.Database( file );
} catch(err) {
// console.log(err);
my._db = new sql.Database();
my.write();
}

function tableify(table) {
var output = '';
for ( var x = 0; x < table.length; x++ ) {
output += '<table class="table table-striped table-condensed">';

// making table headers
output += '<tr>';
for ( var i = 0; i < table[x].columns.length; i++ ) {
output += `<th> ${table[x].columns[i]} </th>`;
}
output += '</tr>';

// making data
for ( var row = 0; row < table[x].values.length; row++ ) {
output += '<tr>';
for ( var col = 0; col < table[x].values[row].length; col++ ) {
output += `<td> ${table[x].values[row][col]} </td>`;
}
output += '</tr>';
}

output += '</table>';
}
return output;
}

return my;
};
7 changes: 6 additions & 1 deletion src/js/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ function pointsSetup() {
pointsSettings = {
enabled: true,
unit: "points",
regularPoints: 999999,
regularPoints: 30*60,
pointsPerUpdate: 1,
minutesPerUpdate: 1,
ranks: [], // {name: string, points: int}
users: [] // {username: string, totalPoints: int, currentPoints: int }
};
}

$("#regularPoints").val( parseInt(pointsSettings.regularPoints / 60) );
$("#regularPoints").on( "input", function() {
pointsSettings.regularPoints = this.value * 60;
} );

$("#pointUnits").val( pointsSettings.unit );
$("#pointUnits").on( "input", function() {
pointsSettings.unit = this.value;
Expand Down
41 changes: 13 additions & 28 deletions src/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var currentUsers = [];
var recentEvents = [];
var mainwin;
var gui;
var sql;

var rawIrcOn = false;
var commandsOn = true;
Expand All @@ -43,7 +44,7 @@ var settings = {
theme: "default"
};

var title = "KoalaBot 0.9.1";
var title = "KoalaBot 0.9.2";

$(document).ready( function() {

Expand All @@ -59,6 +60,8 @@ $(document).ready( function() {
execPath = "";
}

sql = require( 'sql.js' );

gui = require("nw.gui");
mainwin = gui.Window.get();
mainwin.on("close", function() {
Expand Down Expand Up @@ -573,44 +576,28 @@ function getTimeStamp() {

function save() {
// saving settings.ini
fs.writeFile( `${execPath}settings/settings.ini`, JSON.stringify( settings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/settings.ini`, JSON.stringify( settings ) );

// saving modSettings.ini
fs.writeFile( `${execPath}settings/modSettings.ini`, JSON.stringify( modSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/modSettings.ini`, JSON.stringify( modSettings ) );

// saving timedMessages.ini
fs.writeFile( `${execPath}settings/timedMessages.ini`, JSON.stringify( timedMessages ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/timedMessages.ini`, JSON.stringify( timedMessages ) );

// saving cmdSettings.ini
fs.writeFile( `${execPath}settings/cmdSettings.ini`, JSON.stringify( cmdSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/cmdSettings.ini`, JSON.stringify( cmdSettings ) );

// saving raffleSettings.ini
fs.writeFile( `${execPath}settings/raffleSettings.ini`, JSON.stringify( raffleSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/raffleSettings.ini`, JSON.stringify( raffleSettings ) );

// saving eventSettings.ini
fs.writeFile( `${execPath}settings/eventSettings.ini`, JSON.stringify( eventSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/eventSettings.ini`, JSON.stringify( eventSettings ) );

// saving songSettings.ini
fs.writeFile( `${execPath}settings/songSettings.ini`, JSON.stringify( songSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/songSettings.ini`, JSON.stringify( songSettings ) );

// saving defaultCommands.ini
fs.writeFile( `${execPath}settings/defaultCommands.ini`, JSON.stringify( defaultCommands ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/defaultCommands.ini`, JSON.stringify( defaultCommands ) );

// saving pointsSettings.ini
if ( pointsSettings.users ) {
Expand All @@ -634,9 +621,7 @@ function save() {
users: tempUserArray
};

fs.writeFile( `${execPath}settings/pointsSettings.ini`, JSON.stringify( tempPointsSettings ), function ( err ) {
if ( err ) console.log( err );
} );
fs.writeFile( `${execPath}settings/pointsSettings.ini`, JSON.stringify( tempPointsSettings ) );
}

console.log("Settings saved");
Expand Down
Loading

0 comments on commit 8b0a8db

Please sign in to comment.