Skip to content

Commit

Permalink
Added a command page
Browse files Browse the repository at this point in the history
This is going to be reworked a whole lot. Will eventually exclude
disabled commands / modules and look way more fancy.
  • Loading branch information
Mstiekema committed Jan 29, 2017
1 parent ee19f8b commit 4fcfe91
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 67 deletions.
66 changes: 33 additions & 33 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ connection.query(
'id INT AUTO_INCREMENT PRIMARY KEY,' +
'name VARCHAR(30),' +
'points INT,' +
'num_lines INT,' +
'level INT,' +
'num_lines INT,' +
'level INT,' +
'isMod BOOL DEFAULT FALSE)',
function (err, result) {if (err) {return}}
)
Expand All @@ -20,7 +20,7 @@ connection.query(
'game VARCHAR(100),' +
'vod VARCHAR(100),' +
'lowView INT,' +
'currView INT,' +
'currView INT,' +
'highView INT)',
function (err, result) {if (err) {return}}
)
Expand All @@ -31,7 +31,7 @@ connection.query(
'commName VARCHAR(50),' +
'response VARCHAR(500),' +
'commDesc VARCHAR(500),' +
'commUse VARCHAR(500),' +
'commUse TEXT,' +
'level INT DEFAULT 100,' +
'cdType VARCHAR(50),' +
'cd INT)',
Expand Down Expand Up @@ -94,34 +94,34 @@ connection.query(
function (err, result) {if (err) {return}}
)

// connection.query('insert into user set ? ', {"name": options.identity.admin, "points": 0, "num_lines": 0, "level": 500, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
// if (options.identity.admin != options.channels[0]) {
// connection.query('insert into user set ? ', {"name": options.channels[0], "points": 0, "num_lines": 0, "level": 400, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
// connection.query('insert into user set ? ', {"name": options.identity.username, "points": 0, "num_lines": 0, "level": 300, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
// } else {
// connection.query('insert into user set ? ', {"name": options.identity.username, "points": 0, "num_lines": 0, "level": 300, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
// }
connection.query('insert into user set ? ', {"name": options.identity.admin, "points": 0, "num_lines": 0, "level": 500, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
if (options.identity.admin != options.channels[0]) {
connection.query('insert into user set ? ', {"name": options.channels[0], "points": 0, "num_lines": 0, "level": 400, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
connection.query('insert into user set ? ', {"name": options.identity.username, "points": 0, "num_lines": 0, "level": 300, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
} else {
connection.query('insert into user set ? ', {"name": options.identity.username, "points": 0, "num_lines": 0, "level": 300, "isMod": true }, function (err, result) {if (err) {console.log(err)}})
}

// var sql = "insert into module (moduleName, moduleDescription, state) values ?";
// var moduleSettings = [
// ["dungeonActive", "Dungeon", false],
// ['useTwitchAPI', "All the commands that use the Twitch API to fetch data", true],
// ['basicCommands', "Some of the bais commands to use", true],
// ['updateProfile', "Creates a profile for each user with points, lines, etc.", true],
// ['fetchProfile', "Fetches information from all users, such as points and lines", true],
// ['owCommands', "Used to fetch the rank of any OW player", true],
// ['roulette', "Point gambling mini-game", true],
// ['slot', "Point gambling mini-game", true],
// ['dungeon', "Point gambling mini-game with the entire chat", true],
// ['fourtwenty', "Timer that notifies chat it's 16:20", true],
// ['twitter', "Pushes the users Twitter each 20 minutes", true],
// ['getSongs', "Songrequest from chat (player still buggy)", true],
// ['mod', "Module that enables purge, timeout and ban words to be enabled", true],
// ['link', "Gives non-subs a 20 second timeout if they post a link in chat", true],
// ['sub', "Notifies chat if a user subs or resubs", true],
// ['timeout', "Saves a log if a user is timed out or banned", true],
// ];
// connection.query(sql, [moduleSettings], function (err, result) {if (err) {console.log(err)}})
var sql = "insert into module (moduleName, moduleDescription, state) values ?";
var moduleSettings = [
["dungeonActive", "Dungeon", false],
['useTwitchAPI', "All the commands that use the Twitch API to fetch data", true],
['basicCommands', "Some of the bais commands to use", true],
['updateProfile', "Creates a profile for each user with points, lines, etc.", true],
['fetchProfile', "Fetches information from all users, such as points and lines", true],
['owCommands', "Used to fetch the rank of any OW player", true],
['roulette', "Point gambling mini-game", true],
['slot', "Point gambling mini-game", true],
['dungeon', "Point gambling mini-game with the entire chat", true],
['fourtwenty', "Timer that notifies chat it's 16:20", true],
['twitter', "Pushes the users Twitter each 20 minutes", true],
['getSongs', "Songrequest from chat (player still buggy)", true],
['mod', "Module that enables purge, timeout and ban words to be enabled", true],
['link', "Gives non-subs a 20 second timeout if they post a link in chat", true],
['sub', "Notifies chat if a user subs or resubs", true],
['timeout', "Saves a log if a user is timed out or banned", true],
];
connection.query(sql, [moduleSettings], function (err, result) {if (err) {console.log(err)}})

var sql2 = "insert into commands (commName, response, commDesc, cdType, cd, level, commUse) values ?"
var standardCommands = [
Expand All @@ -141,7 +141,7 @@ var standardCommands = [
["!lines", null, "Returns the amount of lines the user has typed", "global", 20, 100, null],
["!totallines", null, "Returns the total recorded lines in chat", "global", 30, 100, null],
["!currentsong", null, "Returns the song that's currently playing", "global", 1, 100, null],
["!songrequest", null, "Allows subs to request songs in chat", "global", 10, 150, "!songrequest Enjoy the silence - Depeche Mode \n !songrequest https://www.youtube.com/watch?v=aGSKrC7dGcY \n !songrequest aGSKrC7dGcY"],
["!songrequest", null, "Allows subs to request songs in chat", "global", 10, 150, "!songrequest Enjoy the silence - Depeche Mode | !songrequest https://www.youtube.com/watch?v=aGSKrC7dGcY | !songrequest aGSKrC7dGcY"],
["!resetpoints", null, "Resets the points of the target", "global", 10, 300, "!resetpoints Mstiekema"],
["!addpoints", null, "Adds points to the target", "user", 1,300, "!addpoints kimodaptyl 12345"],
["!addcommand", null, "Adds a command to the bot", "user", 1, 300, "!addcommand !test This is a testing command :)"],
Expand All @@ -153,4 +153,4 @@ var standardCommands = [
]
connection.query(sql2, [standardCommands], function (err, result) {if (err) console.log(err)})

connection.end();
connection.end();
39 changes: 29 additions & 10 deletions static/css/yucibot.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
color: #a2a8b7;
}

.commands {
background-color: rgb(45, 55, 64);
border: 1px solid gray;
padding-left: 20px;
margin-right: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;;
float: bottom;
}

#subCommands {
background-color: rgb(33, 57, 80);
}

#modCommands {
background-color: rgb(31, 45, 59);
}

.twitch {
width: 1350px;
}
Expand Down Expand Up @@ -201,7 +220,7 @@

.top {
position:absolute;
left:200px;
left:200px;
top: 0;
right:0;
height: 200px;
Expand All @@ -211,8 +230,8 @@
}
.menu {
position:absolute;
left:0;
top:100px;
left:0;
top:100px;
bottom: 0px;
width: 200px;
background-color: #22292b;
Expand All @@ -221,9 +240,9 @@
}
.main {
position: absolute;
left:200px;
top:100px;
right:0;
left:200px;
top:100px;
right:0;
bottom:0;
padding-left: 20px;
background-color: #2f3a3c;
Expand All @@ -243,7 +262,7 @@
margin: 0px;
}

div.menu p:hover, div.login p:hover, div#logMenu p:hover {
div.menu p:hover, div.login p:hover, div#logMenu p:hover {
background-color: #384447;
}

Expand All @@ -258,7 +277,7 @@ div.menu h3 {
footer {
padding: 1em;
text-align: center;
position: absolute;
position: absolute;
bottom: 0;
}

Expand All @@ -273,7 +292,7 @@ body {
overflow: hidden;
}

table, th, td {
.moduleTable td, th {
border: 1px solid black;
text-align: left;
}
Expand All @@ -284,4 +303,4 @@ th, td {

a {
color: #4995c7;
}
}
16 changes: 8 additions & 8 deletions templates/admin/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
var socket = io.connect('<%= website %>');
function disableModule(name) {
socket.emit('disableModule', name)
setTimeout(function() {window.location.reload(true)}, 100);
setTimeout(function() {window.location.reload(true)}, 100);
}
function enableModule(name) {
socket.emit('enableModule', name)
setTimeout(function() {window.location.reload(true)}, 100);
setTimeout(function() {window.location.reload(true)}, 100);
}
</script>
<div class="top"><h1>Modules</h1></div>
Expand All @@ -16,18 +16,18 @@

<h2>Enable / disable modules</h2>
<p>You can enable or disable all the modules here. <br> You'll have to restart the bot for the changes to take effect.</p>
<table>
<table class="moduleTable">
<tr>
<th>Module</th>
<th>State</th>
<th>Description</th>
<th>State</th>
<th>Description</th>
<th>Change</th>
</tr>
<% moduleList.forEach(function(moduleList) { %>
<tr>
<td><%= moduleList.moduleName %></td>
<td><%= moduleList.state %></td>
<td><%= moduleList.moduleDescription %></td>
<td><%= moduleList.state %></td>
<td><%= moduleList.moduleDescription %></td>
<td>
<button onclick="disableModule('<%= moduleList.moduleName %>')">Disable</button>
<button onclick="enableModule('<%= moduleList.moduleName %>')">Enable</button>
Expand All @@ -38,4 +38,4 @@ <h2>Enable / disable modules</h2>

</div>
<script type="text/javascript" src="/../js/yucisite.js"></script>
</body>
</body>
37 changes: 34 additions & 3 deletions templates/commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,39 @@
<div class="search"><input id="searchBar" type="text"></div>
<div class="main">

<p>Commands test page</p>

<% commands.forEach(function(commands) { %>
<% if (commands.level == 100) { %>
<div class="commands"><p>
<b>Command:</b> <%= commands.commName %> <br>
<% if (commands.commDesc != null) { %> <b>Description:</b> <%= commands.commDesc %> <br> <% } %>
<% if (commands.response != null) { %><b>Response:</b> <%= commands.response %> <br> <% } %>
<% if (commands.commUse != null) { %> <b>Usage:</b><br> <%= commands.commUse %> <br> <% } %>
<b>Cooldown type:</b> <%= commands.cdType %> <br>
<b>Cooldown:</b> <%= commands.cd %> seconds <br>
<b>User level:</b> Everyone
</p></div>
<% } else if (commands.level == 150) { %>
<div class="commands" id="subCommands"><p>
<b>Command:</b> <%= commands.commName %> <br>
<% if (commands.commDesc != null) { %> <b>Description:</b> <%= commands.commDesc %> <br> <% } %>
<% if (commands.response != null) { %><b>Response:</b> <%= commands.response %> <br> <% } %>
<% if (commands.commUse != null) { %> <b>Usage:</b> <br><%- commands.commUse.split("|").join("<br>") %> <br> <% } %>
<b>Cooldown type:</b> <%= commands.cdType %> <br>
<b>Cooldown:</b> <%= commands.cd %> seconds <br>
<b>User level:</b> Subscriber
</p></div>
<% } else { %>
<div class="commands" id="modCommands"><p>
<b>Command:</b> <%= commands.commName %> <br>
<% if (commands.commDesc != null) { %> <b>Description:</b> <%= commands.commDesc %> <br> <% } %>
<% if (commands.response != null) { %><b>Response:</b> <%= commands.response %> <br> <% } %>
<% if (commands.commUse != null) { %> <b>Usage:</b><br> <%= commands.commUse %> <br> <% } %>
<b>Cooldown type:</b> <%= commands.cdType %> <br>
<b>Cooldown:</b> <%= commands.cd %> seconds <br>
<b>User level:</b> Moderator
</p></div>
<% } %>
<% }) %>
</div>
<script type="text/javascript" src="../js/yucisite.js"></script>
</body>
</body>
30 changes: 17 additions & 13 deletions website.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ app.all('*', function(req, res, next) {
} else {
if (result[0].isMod == 1) {
res.locals.login = true,
res.locals.mod = true,
res.locals.mod = true,
res.locals.name = req.user
} else {
res.locals.login = true,
res.locals.mod = false,
res.locals.mod = false,
res.locals.name = req.user
}
};
});
});
} else {
res.locals.login = false
}
Expand Down Expand Up @@ -170,7 +170,7 @@ app.get('/user/:id/logs', function(req, res) {
if (result[0] == undefined) {
res.render("error404.html");
} else {
res.render('logs.html', {
res.render('logs.html', {
log: result,
name: result[0].name
});
Expand All @@ -179,7 +179,11 @@ app.get('/user/:id/logs', function(req, res) {
});

app.get('/commands', function(req, res) {
connection.query('select * from commands', function(err, result) {res.render('commands.html')});
connection.query('select * from commands ORDER BY level', function(err, result) {
res.render('commands.html', {
commands: result
})
});
});

app.get('/stats', function(req, res) {
Expand Down Expand Up @@ -240,13 +244,13 @@ app.get('/history/:id', function(req, res) {
} else {
connection.query('select * from songrequest where playState = 0 AND DATE_FORMAT(time,"%Y-%m-%d") = ? ORDER BY id LIMIT 1', req.params.id, function(err, result) {
if (result == undefined || result[0] == undefined) {
res.render('history.html', {
res.render('history.html', {
currSong: [{"title": "The songlist has finished"}],
songInfo: songInfo,
listDate: req.params.id
});
} else {
res.render('history.html', {
res.render('history.html', {
currSong: result,
songInfo: songInfo,
listDate: req.params.id
Expand Down Expand Up @@ -324,7 +328,7 @@ app.get('/admin/logs', function(req, res) {
log: false
});
} else {
res.render('admin/adminlogs.html', {
res.render('admin/adminlogs.html', {
log: result
});
};
Expand All @@ -338,7 +342,7 @@ app.get('/admin/logs/login', function(req, res) {
log: false
});
} else {
res.render('admin/adminlogs.html', {
res.render('admin/adminlogs.html', {
log: result
});
};
Expand All @@ -352,7 +356,7 @@ app.get('/admin/logs/points', function(req, res) {
log: false
});
} else {
res.render('admin/adminlogs.html', {
res.render('admin/adminlogs.html', {
log: result
});
};
Expand All @@ -366,7 +370,7 @@ app.get('/admin/logs/sub', function(req, res) {
log: false
});
} else {
res.render('admin/adminlogs.html', {
res.render('admin/adminlogs.html', {
log: result
});
};
Expand All @@ -380,7 +384,7 @@ app.get('/admin/logs/timeout', function(req, res) {
log: false
});
} else {
res.render('admin/adminlogs.html', {
res.render('admin/adminlogs.html', {
log: result
});
};
Expand All @@ -389,7 +393,7 @@ app.get('/admin/logs/timeout', function(req, res) {

app.get('/admin/modules', function(req, res) {
connection.query('select * from module WHERE id != 1', function(err, result) {
res.render('admin/modules.html', {
res.render('admin/modules.html', {
moduleList: result,
website: options.identity.websiteUrl
});
Expand Down

0 comments on commit 4fcfe91

Please sign in to comment.