diff --git a/ladder.jade b/ladder.jade
deleted file mode 100644
index 41e14fb..0000000
--- a/ladder.jade
+++ /dev/null
@@ -1,71 +0,0 @@
-//-
- title: __self.title,
- slogan: __self.slogan,
- logo: __self.logo,
- twitter: __self.twitter,
-//-
-
-doctype html
-html(lang="en")
- head
- title= title
- link(rel='stylesheet', href='/lib/uikit/css/uikit.almost-flat.min.css')
- link(rel='stylesheet', href='/css/app.css')
- script(src='/lib/jquery.js')
- script(src='/lib/uikit/js/uikit.min.js')
- body
- div.uk-grid
- div.uk-width-1-1
- div.uk-grid
- div.uk-width-1-4
- img(src='/img/#{logo}')
- div.uk-width-2-4
- // bigimagelogo
- h1.uk-text-center #{title}
#{slogan}
- div.uk-width-1-4
- img.flip(src='/img/#{logo}')
- div.uk-width-1-1
- nav.uk-navbar
- ul.uk-navbar-nav.uk-navbar-center
- li: a(href='http://www.twitch.tv/#{title}'): img(src='/img/twitch.png', alt='Stream')
- li: a(href='#') Home
- li: a(href='#') Ladder
- li: a(href='#') Chat Stats
- li: a(href='http://www.twitter.com/#{twitter}'): img(src='/img/twitter.gif', alt='Twitter')
- div.uk-width-1-1
- div.uk-container.uk-container-center
- div.uk-grid
- br
- br
- div.uk-width-1-2
- div.uk-panel.uk-panel-box
- h2 #{title} is
- span#status offline.
- div#streambox
- div.uk-width-1-2
- div.uk-panel.uk-panel-box
- table.uk-table.uk-table-hover.uk-table-striped
- caption Top 10 Potato Farmers
- thead
- tr
- th Viewer
- th Potatoes
- tbody
- each row in rows
- tr
- td #{row.user}
- td #{row.points}
-
- script.
- $(document).ready(function(){
- $.getJSON('https://api.twitch.tv/kraken/streams/#{title}?callback=?', function(data){
- if(data.stream) {
- $('#status').empty().append('online!');
- $("#streambox").append("Game: "+data.stream.game+"
");
- $("#streambox").append("Viewers: "+data.stream.viewers+"
");
- $("#streambox").append("
");;
- } else {
- $("#streambox").append("
Offline
");
- }
- });
- });
diff --git a/lib/currency.js b/lib/currency.js
index b612637..03e26d1 100644
--- a/lib/currency.js
+++ b/lib/currency.js
@@ -131,11 +131,30 @@ function Currency(irc, db, options) {
__self.bets_response = null;
__self.bets_response_timer = 3000;
__self.bets_response_reset = true;
+
+ // high score table
+ __self.score_bet_pool = 0;
+ __self.score_bet_single = 0;
}
//-------- Methods ---------
Currency.prototype.start = function () {
var __self = this;
+
+ // populate highscore holders
+ __self.db.execute('SELECT * FROM highscores', function(rows) {
+ rows.forEach(function(element, index, array){
+ switch(element.name) {
+ case 'bet_pool':
+ __self.score_bet_pool = element.value;
+ break;
+ case 'bet_single':
+ __self.score_bet_single = element.value;
+ break;
+ }
+ });
+ });
+
__self.handout_coins();
};
@@ -243,7 +262,7 @@ Currency.prototype.commands = function (data) {
}
}
- /*
+ // TODO: create a log file that monitors just add/remove/push - greedy mods :D
// add currency
if (data[4] === 'add') {
if(parseInt(data[5], 10) > 0 && data[6]) {
@@ -264,7 +283,6 @@ Currency.prototype.commands = function (data) {
__self.adjust_currency('push', data[5], data[6]);
}
}
- */
}
// moderator commands
@@ -369,9 +387,11 @@ Currency.prototype.commands = function (data) {
}
}
break;
+ // show top currency earners
case '!top':
__self.get_top(data[4]);
break;
+ // show a users ranking in the ladder
case '!rank':
__self.get_rank(__self.irc.caller(data[0]).toLowerCase());
break;
@@ -737,7 +757,7 @@ Currency.prototype.handout_coins = function () {
}
// execute query
- __self.db.execute(sql, function () { console.log('DATA - Completed adding coins to ' + __self.viewer_list.length + ' viewers'); });
+ __self.db.execute(sql, function () {});
setTimeout(insert_coins, 1000);
} else {
setTimeout(insert_coins, time);
@@ -749,14 +769,25 @@ Currency.prototype.handout_coins = function () {
__self.irc.on('data', function (data) {
var data_split = data.split(' '), viewer = '';
- // Processing /names
+ // viewers from \who
+ // TODO: new twitch chat doesn't allow /who, remove this?
+ if (data_split[3] == '352') {
+ if (data_split[6] !== undefined) {
+ viewer = data_split[6].toLowerCase();
+ if (__self.viewer_list.indexOf(viewer) < 0 && __self.config.ignorelist.indexOf(viewer) < 0) {
+ __self.viewer_list.push(viewer);
+ }
+ }
+ }
+
+ // Processing below replaces the now defunct who-calls above
+ // handle /names
if (data_split[3] == '353'){
viewers = data_split.splice(7);
viewers.forEach(function(name) {
if(name.charAt(0) === ':') name = name.slice(1);
if (__self.viewer_list.indexOf(name) < 0 && __self.config.ignorelist.indexOf(name) < 0) {
__self.viewer_list.push(name);
- console.log("[*ADD NAME*] "+name+" from /names");
}
});
}
@@ -770,7 +801,7 @@ Currency.prototype.handout_coins = function () {
}
if (__self.viewer_list.indexOf(viewer) < 0 && __self.config.ignorelist.indexOf(viewer) < 0) {
__self.viewer_list.push(viewer);
- console.log("[*ADD NAME*] "+viewer+" from JOIN");
+ } else {
}
}
@@ -783,8 +814,9 @@ Currency.prototype.handout_coins = function () {
}
var viewer_idx = __self.viewer_list.indexOf(viewer);
if (viewer_idx >= 0) {
- __self.viewer_list.splice(viewer_idx);
- console.log("[*DEL NAME*] "+viewer+" from PART");
+ __self.viewer_list.splice(viewer_idx,1);
+ } else {
+ console.log("[*ERROR*] User "+viewer+" PART'ed but was not in viewer_list.");
}
}
@@ -1462,6 +1494,7 @@ Currency.prototype.bets = function(status, data) {
__self.irc.emit('message', {message:__self.pre_text + 'Betting already in progress'});
}
}
+ // FIXME: messages below should be "cant open a bet until X is over/closed" instead? test it
} else {
// raffle in progress
__self.irc.emit('message', {message:__self.pre_text + 'Betting must be closed before you can open a raffle'});
@@ -1513,7 +1546,15 @@ Currency.prototype.bets = function(status, data) {
for (var i = 0; i < __self.bets_board.length; i++) {
if (data == __self.bets_board[i].name) {
__self.bets_award_winner(__self.bets_board[i]);
- __self.irc.emit('message', {message:__self.pre_text + 'Betting payed out to ' + data});
+ if(__self.bets_board[i].total > __self.score_bet_pool) {
+ sql = 'UPDATE highscores SET value = ' + __self.bets_board[i].total + ' WHERE name = \'bet_pool\'';
+ __self.db.execute(sql, function() {
+ __self.score_bet_pool = __self.bets_board[i].total;
+ __self.irc.emit('message', {message:__self.pre_text + 'Betting payed out to ' + data + '. New record set!!'});
+ });
+ } else {
+ __self.irc.emit('message', {message:__self.pre_text + 'Betting payed out to ' + data});
+ }
}
}
} else {
@@ -1587,6 +1628,16 @@ Currency.prototype.collect_bets = function (caller, bet, amount) {
for (var i = 0; i < rows.length; i++) {
amount = Math.min(amount, rows[i].points);
}
+
+ // check for hiscore and set db appropriately
+ if(amount > __self.score_bet_single) {
+ sql = 'UPDATE highscores SET value = ' + amount + ' WHERE name = \'bet_single\'';
+ __self.db.execute(sql, function() {
+ __self.score_bet_single = amount;
+ __self.irc.emit('message', {message:__self.pre_text + ' ' + caller + ' set new record bet at ' + amount + '!'});
+ });
+ }
+
if (__self.bets_viewers.length > 0) {
for (var i = 0; i < __self.bets_viewers.length; i++) {
if (__self.bets_viewers[i].viewer === caller) {
diff --git a/lib/irc.js b/lib/irc.js
index 5e0a7de..68048dd 100644
--- a/lib/irc.js
+++ b/lib/irc.js
@@ -74,7 +74,7 @@ function IRC(options) {
nick : 'irc_bot',
broadcaster : __self.options.channel.slice(1).charAt(0).toUpperCase() + __self.options.channel.slice(2).toLowerCase(),
// twitch server
- addr : '199.9.250.229', //__self.options.name.toLowerCase() + '.jtvirc.com',
+ addr : 'irc.twitch.tv', //__self.options.name.toLowerCase() + '.jtvirc.com',
port : 6667,
channel : __self.options.channel.toLowerCase(),
encoding : 'ascii'
@@ -240,7 +240,7 @@ IRC.prototype.reconnect = function () {
IRC.prototype.join = function (data) {
var __self = this;
- if (data[3] === ':>') {
+ if (data[3] === ':>' || data[3] === ':End') {
__self.raw('JOIN ' + __self.config.channel);
}
};
diff --git a/lib/mysql.js b/lib/mysql.js
index fdc3377..30028c4 100644
--- a/lib/mysql.js
+++ b/lib/mysql.js
@@ -28,7 +28,7 @@ function DB(options) {
//-------- Methods ---------
DB.prototype.start = function() {
- var __self = this, commands ='', viewers = '';
+ var __self = this, commands ='', viewers = '', scores = '';
// table structure for table commands
commands += 'CREATE TABLE IF NOT EXISTS `commands` (';
@@ -44,10 +44,19 @@ DB.prototype.start = function() {
viewers += '`user` varchar(64) COLLATE utf8_unicode_ci NOT NULL,';
viewers += '`points` int(11) NOT NULL,';
viewers += 'PRIMARY KEY (`user`)';
- viewers += ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;';
+ viewers += ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
+
+ // table structure for table highscores
+ scores += 'CREATE TABLE IF NOT EXISTS `highscores` (';
+ scores += '`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,';
+ scores += '`value` int(11) NOT NULL,';
+ scores += 'PRIMARY KEY (`name`)';
+ scores += ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;';
+ scores += 'INSERT INTO `highscores` (`name`, `value`) VALUES(\'bet_single\', 0);';
+ scores += 'INSERT INTO `highscores` (`name`, `value`) VALUES(\'bet_pool\', 0);';
// execute sql, create tables if they don't exist
- __self.execute(commands + '; ' + viewers, function(){});
+ __self.execute(commands + '; ' + viewers + '; ' + scores, function(){});
};
DB.prototype.execute = function(sql, callback) {
@@ -78,4 +87,4 @@ DB.prototype.execute = function(sql, callback) {
module.exports = function (options) {
return new DB(options);
-};
\ No newline at end of file
+};
diff --git a/web/public/css/app.css b/web/public/css/app.css
deleted file mode 100644
index 813a1d1..0000000
--- a/web/public/css/app.css
+++ /dev/null
@@ -1,17 +0,0 @@
-.uk-navbar-nav > li {
- display: inline-block;
- float: none;
-}
-
-.uk-navbar-nav > li > a > img {
- width: 20px;
-}
-
-.flip {
- transform: scaleX(-1);
- filter: FlipH;
- -ms-filter: "FlipH";
-}
-.uk-search-field, .uk-search-field::-moz-placeholder {
- color: #FFFFFF;
-}
diff --git a/web/templates/index.jade b/web/templates/index.jade
index 092ed08..e81df2c 100755
--- a/web/templates/index.jade
+++ b/web/templates/index.jade
@@ -6,6 +6,24 @@ html(lang="en")
link(rel='stylesheet', href='/css/app.css')
script(src='/lib/jquery.js')
script(src='/lib/uikit/js/uikit.min.js')
+
+ // Favicon stuff
+ link(rel='apple-touch-icon', sizes='57x57', href='/apple-touch-icon-57x57.png')
+ link(rel='apple-touch-icon', sizes='114x114', href='/apple-touch-icon-114x114.png')
+ link(rel='apple-touch-icon', sizes='72x72', href='/apple-touch-icon-72x72.png')
+ link(rel='apple-touch-icon', sizes='144x144', href='/apple-touch-icon-144x144.png')
+ link(rel='apple-touch-icon', sizes='60x60', href='/apple-touch-icon-60x60.png')
+ link(rel='apple-touch-icon', sizes='120x120', href='/apple-touch-icon-120x120.png')
+ link(rel='apple-touch-icon', sizes='76x76', href='/apple-touch-icon-76x76.png')
+ link(rel='apple-touch-icon', sizes='152x152', href='/apple-touch-icon-152x152.png')
+ link(rel='icon', type='image/png', href='/favicon-196x196.png', sizes='196x196')
+ link(rel='icon', type='image/png', href='/favicon-160x160.png', sizes='160x160')
+ link(rel='icon', type='image/png', href='/favicon-96x96.png', sizes='96x96')
+ link(rel='icon', type='image/png', href='/favicon-16x16.png', sizes='16x16')
+ link(rel='icon', type='image/png', href='/favicon-32x32.png', sizes='32x32')
+ meta(name='msapplication-TileColor', content='#da532c')
+ meta(name='msapplication-TileImage', content='/mstile-144x144.png')
+
body
div.uk-grid
div.uk-width-1-1
diff --git a/web/templates/ladder.jade b/web/templates/ladder.jade
index 42ba720..0240f99 100755
--- a/web/templates/ladder.jade
+++ b/web/templates/ladder.jade
@@ -6,6 +6,23 @@ html(lang="en")
link(rel='stylesheet', href='/css/app.css')
script(src='/lib/jquery.js')
script(src='/lib/uikit/js/uikit.min.js')
+
+ // Favicon stuff
+ link(rel='apple-touch-icon', sizes='57x57', href='/apple-touch-icon-57x57.png')
+ link(rel='apple-touch-icon', sizes='114x114', href='/apple-touch-icon-114x114.png')
+ link(rel='apple-touch-icon', sizes='72x72', href='/apple-touch-icon-72x72.png')
+ link(rel='apple-touch-icon', sizes='144x144', href='/apple-touch-icon-144x144.png')
+ link(rel='apple-touch-icon', sizes='60x60', href='/apple-touch-icon-60x60.png')
+ link(rel='apple-touch-icon', sizes='120x120', href='/apple-touch-icon-120x120.png')
+ link(rel='apple-touch-icon', sizes='76x76', href='/apple-touch-icon-76x76.png')
+ link(rel='apple-touch-icon', sizes='152x152', href='/apple-touch-icon-152x152.png')
+ link(rel='icon', type='image/png', href='/favicon-196x196.png', sizes='196x196')
+ link(rel='icon', type='image/png', href='/favicon-160x160.png', sizes='160x160')
+ link(rel='icon', type='image/png', href='/favicon-96x96.png', sizes='96x96')
+ link(rel='icon', type='image/png', href='/favicon-16x16.png', sizes='16x16')
+ link(rel='icon', type='image/png', href='/favicon-32x32.png', sizes='32x32')
+ meta(name='msapplication-TileColor', content='#da532c')
+ meta(name='msapplication-TileImage', content='/mstile-144x144.png')
body
div.uk-grid
div.uk-width-1-1