From 631feab417813ab53ae20a001a57cdf575cf2a91 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Sun, 5 Jan 2014 12:03:03 -0600 Subject: [PATCH 1/9] Added a working betting system, splits the pool amongst winners weighted by their contribution (always at least one more). --- lib/currency.js | 152 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 123 insertions(+), 29 deletions(-) diff --git a/lib/currency.js b/lib/currency.js index 16c06f4..6c8570e 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -120,6 +120,7 @@ function Currency(irc, db, options) { __self.bets_board = []; __self.bets_viewers = []; __self.bets_payout = false; + __self.bets_total = 0; } //-------- Methods --------- @@ -211,8 +212,11 @@ Currency.prototype.commands = function (data) { case 'close': __self.bets(false, null); break; + case 'pool': + __self.bets('pool', null); + break; case 'winner': - //__self.bets('winner'); + __self.bets('winner', data[6]); break; } } @@ -346,7 +350,7 @@ Currency.prototype.commands = function (data) { // place a bet if (__self.bets_status === true) { for (var i = 0; i < __self.bets_board.length; i++) { - if (data[3].slice(1) === '!' + __self.bets_board[i]) { + if (data[3].slice(1) === '!' + __self.bets_board[i].name) { if (isNaN(parseInt(data[4], 10)) === false) { if (data[4] >= 0 && data[4] % 1 === 0) { __self.collect_bets(__self.irc.caller(data[0]), __self.bets_board[i], parseInt(data[4], 10)); @@ -1261,16 +1265,20 @@ Currency.prototype.bets = function(status, data) { // clear previous board / bets __self.bets_board = []; __self.bets_viewers = []; + __self.bets_total = 0; // create new betting board - __self.bets_board = data.join().split(',').filter(function(n){return n}).slice(6); + __self.bets_board = data.join().split(',').filter(function(n){return n}).slice(6).map(function(n){return {name: n, num: 0, total: 0};}); + for (var i = 0; i < __self.bets_board.length; i++) { + __self.bets_board[i].idx = i; + } // create chat message on how to place a bet for (var i = 0; i < __self.bets_board.length; i++) { if (i !== __self.bets_board.length - 1) { - wager_msg += '"!' + __self.bets_board[i] + '" / '; + wager_msg += '"!' + __self.bets_board[i].name + '" / '; } else { - wager_msg += '"!' + __self.bets_board[i] + '"'; + wager_msg += '"!' + __self.bets_board[i].name + '"'; } } @@ -1300,20 +1308,49 @@ Currency.prototype.bets = function(status, data) { // close out bets __self.bets_status = false; + // deduct bets from viewers amounts + __self.bets_deduct_bets(); + // output to chat if (__self.bets_viewers.length > 0) { __self.irc.emit('message', {message:__self.pre_text + 'Betting is now closed'}); + for (var i = 0; i < __self.bets_board.length; i++) { + __self.irc.emit('message', {message:'+ ' + __self.bets_board[i].name + ' with ' + __self.bets_board[i].num + ' bets totaling ' + __self.bets_board[i].total}); + } } else { __self.irc.emit('message', {message:__self.pre_text + 'Betting closed, no bets were placed'}); } - - // deduct bets from viewers amounts - __self.bets_deduct_bets(); + } + break; + case 'pool': + if (__self.bets_board.length > 0) { + __self.irc.emit('message', {message:__self.pre_text + 'Current betting pool is:'}); + for (var i = 0; i < __self.bets_board.length; i++) { + __self.irc.emit('message', {message:'+ ' + __self.bets_board[i].name + ' with ' + __self.bets_board[i].num + ' bets totaling ' + __self.bets_board[i].total}); + } + } else { + __self.irc.emit('message', {message:__self.pre_text + 'No current bet.'}); } break; case 'winner': - // set payout to complete - __self.bets_payout = false; + if (!__self.bets_status) { + if (__self.bets_payout) { + 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}); + } + } + // Clear the board + __self.bets_board = []; + __self.bets_viewers = []; + __self.bets_total = 0; + } else { + __self.irc.emit('message', {message:__self.pre_text + 'Betting has already payed out'}); + } + } else { + __self.irc.emit('message', {message:__self.pre_text + 'Betting must be closed before you can have a winner'}); + } break; } }; @@ -1321,34 +1358,91 @@ Currency.prototype.bets = function(status, data) { Currency.prototype.collect_bets = function (caller, bet, amount) { var __self = this, has_bet = false; - if (__self.bets_viewers.length > 0) { - for (var i = 0; i < __self.bets_viewers.length; i++) { - if (__self.bets_viewers[i].viewer === caller) { - has_bet = true; - if (amount >= 1) { - __self.bets_viewers[i].bet = bet; - __self.bets_viewers[i].amount = amount; - } else if (amount === 0 && bet === __self.bets_viewers[i].bet) { - __self.bets_viewers.splice(i, 1); + // Bound amount by positive currency + __self.query_coins(caller, function (rows) { + for (var i = 0; i < rows.length; i++) { + amount = Math.min(amount, rows[i].points); + } + if (__self.bets_viewers.length > 0) { + for (var i = 0; i < __self.bets_viewers.length; i++) { + if (__self.bets_viewers[i].viewer === caller) { + has_bet = true; + if (amount >= 1) { + __self.bets_board[__self.bets_viewers[i].bet].num -= 1; + __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; + __self.bets_viewers[i].bet = bet.idx; + __self.bets_viewers[i].amount = amount; + __self.bets_board[bet.idx].num += 1; + __self.bets_board[bet.idx].total += amount; + } else { + __self.bets_board[__self.bets_viewers[i].bet].num -= 1; + __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; + __self.bets_viewers.splice(i, 1); + } + break; + } + } + if (!has_bet && amount >= 1 && amount !== 0) { + __self.bets_viewers.push({viewer: caller, bet: bet.idx, amount: amount}); + __self.bets_board[bet.idx].num += 1; + __self.bets_board[bet.idx].total += amount; + } + } else { + if (amount >= 1 && amount !== 0) { + __self.bets_viewers.push({viewer: caller, bet: bet.idx, amount: amount}); + __self.bets_board[bet.idx].num += 1; + __self.bets_board[bet.idx].total += amount; } - break; } + console.log(__self.bets_viewers); + }); +}; + +Currency.prototype.bets_deduct_bets = function () { + var __self = this; + + if (__self.bets_viewers.length > 0) { + // Don't trust the on-the-fly numbers + for (var i = 0; i < __self.bets_board.length; i++) { + __self.bets_board[i].num = 0; + __self.bets_board[i].total = 0; } - if (!has_bet && amount >= 1 && amount !== 0) { - __self.bets_viewers.push({viewer: caller, bet: bet, amount: amount}); - } - } else { - if (amount >= 1 && amount !== 0) { - __self.bets_viewers.push({viewer: caller, bet: bet, amount: amount}); + __self.bets_total = 0; + // Remove the points and add them to an escrow + for (var i = 0; i < __self.bets_viewers.length; i++) { + sql = ''; + sql += 'UPDATE viewers '; + sql += 'SET points = points - ' + __self.bets_viewers[i].amount + ' '; + sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; + __self.db.execute(sql, function() {}); + __self.bets_board[__self.bets_viewers[i].bet].num += 1; + __self.bets_board[__self.bets_viewers[i].bet].total += __self.bets_viewers[i].amount; + __self.bets_total += __self.bets_viewers[i].amount; } } - console.log(__self.bets_viewers); }; -Currency.prototype.bets_deduct_bets = function () { +Currency.prototype.bets_award_winner = function (winner) { + var __self = this; + if (__self.bets_payout) { + // set payout to complete + __self.bets_payout = false; + } + // Remove the points and add them to an escrow + if (__self.bets_viewers.length > 0) { + for (var i = 0; i < __self.bets_viewers.length; i++) { + if (__self.bets_viewers[i].bet == winner.idx) { + sql = ''; + sql += 'UPDATE viewers '; + sql += 'SET points = points + ' + Math.ceil(__self.bets_total * __self.bets_viewers[i].amount / __self.bets_board[__self.bets_viewers[i].bet].total) + ' '; + sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; + __self.db.execute(sql, function() {}); + } + } + } }; module.exports = function (irc, db, options) { return new Currency(irc, db, options); -}; \ No newline at end of file +}; From e4ab6185da43b678681a4f5de6a65ad1ea969380 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 6 Jan 2014 14:49:08 -0600 Subject: [PATCH 2/9] Adding betting feedback using the flood/timer mechanism from currency checks. --- lib/currency.js | 79 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/lib/currency.js b/lib/currency.js index 6c8570e..6d05aa5 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -121,6 +121,10 @@ function Currency(irc, db, options) { __self.bets_viewers = []; __self.bets_payout = false; __self.bets_total = 0; + __self.bets_flood = []; + __self.bets_response = null; + __self.bets_response_timer = 3000; + __self.bets_response_reset = true; } //-------- Methods --------- @@ -1358,6 +1362,30 @@ Currency.prototype.bets = function(status, data) { Currency.prototype.collect_bets = function (caller, bet, amount) { var __self = this, has_bet = false; + function do_work() { + var multi_response = []; + for (var i = 0; i < __self.bets_board.length; i++) { + multi_response.push([]); + } + + if (__self.bets_flood.length > 0) {// send flood requests + var bet; + // setup bet response + for (var i = 0; i < __self.bets_flood.length; i++) { + bet = __self.bets_viewers[__self.bets_flood[i]]; + multi_response[bet.bet].push(bet.viewer + ' (' + bet.amount + ')'); + } + for (var i = 0; i < __self.bets_board.length; i++) { + if (multi_response[i].length > 0) { + __self.irc.emit('message', {message:'New bets for ' + __self.bets_board[i].name + ': ' + multi_response[i].join(', '), timer: 1}); + } + } + } + + // clear flood requests + __self.bets_flood = []; + } + // Bound amount by positive currency __self.query_coins(caller, function (rows) { for (var i = 0; i < rows.length; i++) { @@ -1367,17 +1395,20 @@ Currency.prototype.collect_bets = function (caller, bet, amount) { for (var i = 0; i < __self.bets_viewers.length; i++) { if (__self.bets_viewers[i].viewer === caller) { has_bet = true; + __self.bets_board[__self.bets_viewers[i].bet].num -= 1; + __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; + __self.bets_viewers[i].bet = bet.idx; + __self.bets_viewers[i].amount = amount; if (amount >= 1) { - __self.bets_board[__self.bets_viewers[i].bet].num -= 1; - __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; - __self.bets_viewers[i].bet = bet.idx; - __self.bets_viewers[i].amount = amount; __self.bets_board[bet.idx].num += 1; __self.bets_board[bet.idx].total += amount; - } else { - __self.bets_board[__self.bets_viewers[i].bet].num -= 1; - __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; - __self.bets_viewers.splice(i, 1); + // add flood users to array + if (__self.bets_flood.indexOf(i) < 0) { + __self.bets_flood.push(i); + } + // remove from flood if nullified bet + } else if (__self.bets_flood.indexOf(i) > 0) { + __self.bets_flood.splice(__self.bets_flood.indexOf(i), 1); } break; } @@ -1386,15 +1417,29 @@ Currency.prototype.collect_bets = function (caller, bet, amount) { __self.bets_viewers.push({viewer: caller, bet: bet.idx, amount: amount}); __self.bets_board[bet.idx].num += 1; __self.bets_board[bet.idx].total += amount; + __self.bets_flood.push(__self.bets_viewers.length - 1); } } else { if (amount >= 1 && amount !== 0) { __self.bets_viewers.push({viewer: caller, bet: bet.idx, amount: amount}); __self.bets_board[bet.idx].num += 1; __self.bets_board[bet.idx].total += amount; + __self.bets_flood.push(__self.bets_viewers.length - 1); } } console.log(__self.bets_viewers); + + // check if flood has a set amount of requests and output + // if not, set the output timer + if (__self.bets_flood.length === __self.max_requests) { + do_work(); + } else { + if (__self.bets_response_reset) { + __self.bets_response = setTimeout(function () {do_work();}, __self.bets_response_timer); + } else { + setTimeout(function () {do_work();}, __self.bets_response_timer); + } + } }); }; @@ -1410,14 +1455,16 @@ Currency.prototype.bets_deduct_bets = function () { __self.bets_total = 0; // Remove the points and add them to an escrow for (var i = 0; i < __self.bets_viewers.length; i++) { - sql = ''; - sql += 'UPDATE viewers '; - sql += 'SET points = points - ' + __self.bets_viewers[i].amount + ' '; - sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; - __self.db.execute(sql, function() {}); - __self.bets_board[__self.bets_viewers[i].bet].num += 1; - __self.bets_board[__self.bets_viewers[i].bet].total += __self.bets_viewers[i].amount; - __self.bets_total += __self.bets_viewers[i].amount; + if (__self.bets_viewers[i].amount > 0) { + sql = ''; + sql += 'UPDATE viewers '; + sql += 'SET points = points - ' + __self.bets_viewers[i].amount + ' '; + sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; + __self.db.execute(sql, function() {}); + __self.bets_board[__self.bets_viewers[i].bet].num += 1; + __self.bets_board[__self.bets_viewers[i].bet].total += __self.bets_viewers[i].amount; + __self.bets_total += __self.bets_viewers[i].amount; + } } } }; From 1636a8a07ec87d5bd75e548240f59740bad55506 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 6 Jan 2014 14:50:41 -0600 Subject: [PATCH 3/9] Added bet pool to a flood timer as well. --- lib/currency.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/currency.js b/lib/currency.js index 6d05aa5..0d66fd9 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -1327,13 +1327,20 @@ Currency.prototype.bets = function(status, data) { } break; case 'pool': - if (__self.bets_board.length > 0) { - __self.irc.emit('message', {message:__self.pre_text + 'Current betting pool is:'}); - for (var i = 0; i < __self.bets_board.length; i++) { - __self.irc.emit('message', {message:'+ ' + __self.bets_board[i].name + ' with ' + __self.bets_board[i].num + ' bets totaling ' + __self.bets_board[i].total}); + function do_work() { + if (__self.bets_board.length > 0) { + __self.irc.emit('message', {message:__self.pre_text + 'Current betting pool is:'}); + for (var i = 0; i < __self.bets_board.length; i++) { + __self.irc.emit('message', {message:'+ ' + __self.bets_board[i].name + ' with ' + __self.bets_board[i].num + ' bets totaling ' + __self.bets_board[i].total}); + } + } else { + __self.irc.emit('message', {message:__self.pre_text + 'No current bet.'}); } + } + if (__self.bets_response_reset) { + __self.bets_response = setTimeout(function () {do_work();}, __self.bets_response_timer); } else { - __self.irc.emit('message', {message:__self.pre_text + 'No current bet.'}); + setTimeout(function () {do_work();}, __self.bets_response_timer); } break; case 'winner': From c1c0f42189edb72f81f6bb704184e2ff257f8a55 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 6 Jan 2014 14:51:05 -0600 Subject: [PATCH 4/9] Fixing a typo in the opening bet check. --- lib/currency.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/currency.js b/lib/currency.js index 0d66fd9..f41bc33 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -207,7 +207,7 @@ Currency.prototype.commands = function (data) { if (data[4] === 'bet') { switch (data[5]) { case 'open': - if (data[5] && data[6]) { + if (data[6] && data[7]) { __self.bets(true, data); } else { __self.irc.emit('message', {message:__self.pre_text + 'Unable to open betting, need at least two items to bet against'}); From 9a8617e6d49a252756d175abac36e62e36bd4c51 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 6 Jan 2014 20:53:22 -0600 Subject: [PATCH 5/9] Fixing a bug where the first mod was not registering properly for commands. --- lib/currency.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/currency.js b/lib/currency.js index f41bc33..1d37404 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -136,7 +136,7 @@ Currency.prototype.start = function () { Currency.prototype.commands = function (data) { var __self = this, broadcaster_bot_initiated = __self.irc.caller(data[0]).toLowerCase() === __self.irc.config.broadcaster.toLowerCase() || __self.irc.caller(data[0]).toLowerCase() === __self.irc.config.name.toLowerCase(), - moderator_initiated = __self.irc.mods.indexOf(__self.irc.caller(data[0])) > 0; + moderator_initiated = __self.irc.mods.indexOf(__self.irc.caller(data[0])) >= 0; // handle ! commands if (data[3].slice(1) === '!' + __self.config.currency.toLowerCase()) { From b2743627d3b069ad5c99f78dc77633f26113bdce Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 6 Jan 2014 20:53:48 -0600 Subject: [PATCH 6/9] Only allowing increased bets to override previous ones. --- lib/currency.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/currency.js b/lib/currency.js index 1d37404..e5554e1 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -1402,20 +1402,17 @@ Currency.prototype.collect_bets = function (caller, bet, amount) { for (var i = 0; i < __self.bets_viewers.length; i++) { if (__self.bets_viewers[i].viewer === caller) { has_bet = true; - __self.bets_board[__self.bets_viewers[i].bet].num -= 1; - __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; - __self.bets_viewers[i].bet = bet.idx; - __self.bets_viewers[i].amount = amount; - if (amount >= 1) { + if (amount > __self.bets_viewers[i].amount) { + __self.bets_board[__self.bets_viewers[i].bet].num -= 1; + __self.bets_board[__self.bets_viewers[i].bet].total -= __self.bets_viewers[i].amount; + __self.bets_viewers[i].bet = bet.idx; + __self.bets_viewers[i].amount = amount; __self.bets_board[bet.idx].num += 1; __self.bets_board[bet.idx].total += amount; // add flood users to array if (__self.bets_flood.indexOf(i) < 0) { __self.bets_flood.push(i); } - // remove from flood if nullified bet - } else if (__self.bets_flood.indexOf(i) > 0) { - __self.bets_flood.splice(__self.bets_flood.indexOf(i), 1); } break; } From be552aa011691e308ccd2713ffe37e7a476737ac Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Fri, 10 Jan 2014 00:46:16 -0600 Subject: [PATCH 7/9] Fixing a bug where declaring an invalid bet winner wiped out the bet information. --- lib/currency.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/currency.js b/lib/currency.js index e5554e1..b1f3827 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -1352,10 +1352,6 @@ Currency.prototype.bets = function(status, data) { __self.irc.emit('message', {message:__self.pre_text + 'Betting payed out to ' + data}); } } - // Clear the board - __self.bets_board = []; - __self.bets_viewers = []; - __self.bets_total = 0; } else { __self.irc.emit('message', {message:__self.pre_text + 'Betting has already payed out'}); } @@ -1458,18 +1454,21 @@ Currency.prototype.bets_deduct_bets = function () { } __self.bets_total = 0; // Remove the points and add them to an escrow + sql = ''; for (var i = 0; i < __self.bets_viewers.length; i++) { if (__self.bets_viewers[i].amount > 0) { - sql = ''; + if (sql.length > 0) { + sql += '; '; + } sql += 'UPDATE viewers '; sql += 'SET points = points - ' + __self.bets_viewers[i].amount + ' '; sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; - __self.db.execute(sql, function() {}); __self.bets_board[__self.bets_viewers[i].bet].num += 1; __self.bets_board[__self.bets_viewers[i].bet].total += __self.bets_viewers[i].amount; __self.bets_total += __self.bets_viewers[i].amount; } } + __self.db.execute(sql, function() {}); } }; @@ -1480,18 +1479,25 @@ Currency.prototype.bets_award_winner = function (winner) { // set payout to complete __self.bets_payout = false; } - // Remove the points and add them to an escrow + // Payout the points if (__self.bets_viewers.length > 0) { + sql = ''; for (var i = 0; i < __self.bets_viewers.length; i++) { if (__self.bets_viewers[i].bet == winner.idx) { - sql = ''; + if (sql.length > 0) { + sql += '; '; + } sql += 'UPDATE viewers '; sql += 'SET points = points + ' + Math.ceil(__self.bets_total * __self.bets_viewers[i].amount / __self.bets_board[__self.bets_viewers[i].bet].total) + ' '; sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; - __self.db.execute(sql, function() {}); } } + __self.db.execute(sql, function() {}); } + // Clear the board + __self.bets_board = []; + __self.bets_viewers = []; + __self.bets_total = 0; }; module.exports = function (irc, db, options) { From bd433920828bb47686d679953ada5d57dfa97f28 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 13 Jan 2014 14:11:08 -0600 Subject: [PATCH 8/9] Added a bet cancel command. --- lib/currency.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/currency.js b/lib/currency.js index b1f3827..ac534fe 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -222,6 +222,9 @@ Currency.prototype.commands = function (data) { case 'winner': __self.bets('winner', data[6]); break; + case 'cancel': + __self.bets('cancel'); + break; } } @@ -1359,6 +1362,35 @@ Currency.prototype.bets = function(status, data) { __self.irc.emit('message', {message:__self.pre_text + 'Betting must be closed before you can have a winner'}); } break; + case 'cancel': + if (!__self.bets_status) { + // Return all the currency back to original owners + if (__self.bets_payout) { + sql = ''; + for (var i = 0; i < __self.bets_viewers.length; i++) { + if (__self.bets_viewers[i].amount > 0) { + if (sql.length > 0) { + sql += '; '; + } + sql += 'UPDATE viewers '; + sql += 'SET points = points + ' + __self.bets_viewers[i].amount + ' '; + sql += 'WHERE user = \'' + __self.bets_viewers[i].viewer + '\''; + } + } + __self.db.execute(sql, function() { + __self.irc.emit('message', {message:__self.pre_text + 'Bet was canceled, all ' + __self.config.currency.toLowerCase() + ' returned.'}); + }); + __self.bets_payout = false; + // Or just cancel the bets + } else { + __self.irc.emit('message', {message:__self.pre_text + 'No bet to cancel.'}); + } + } else { + __self.bets_status = false; + __self.bets_payout = false; + __self.irc.emit('message', {message:__self.pre_text + 'Current bet was canceled.'}); + } + break; } }; From d0e0441fbf48e1a81e8134432ced6b516177f555 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Mon, 13 Jan 2014 14:12:31 -0600 Subject: [PATCH 9/9] Added some basic help commands to raffle/bet/auction. --- lib/currency.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/currency.js b/lib/currency.js index ac534fe..f4b71c4 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -162,6 +162,9 @@ Currency.prototype.commands = function (data) { case 'cancel': __self.auction('cancel'); break; + case 'help': + __self.irc.emit('message', {message:__self.pre_text + '!' + __self.config.currency.toLowerCase() + ' auction open/close/cancel/draw'}); + break; } } @@ -200,6 +203,9 @@ Currency.prototype.commands = function (data) { case 'restore': __self.raffle('restore'); break; + case 'help': + __self.irc.emit('message', {message:__self.pre_text + '!' + __self.config.currency.toLowerCase() + ' raffle open /close/cancel/draw/restore'}); + break; } } @@ -225,6 +231,9 @@ Currency.prototype.commands = function (data) { case 'cancel': __self.bets('cancel'); break; + case 'help': + __self.irc.emit('message', {message:__self.pre_text + '!' + __self.config.currency.toLowerCase() + ' bet open