From 10b6c452152c618ac4980f0987288970300df2a5 Mon Sep 17 00:00:00 2001 From: Brandon Cornejo Date: Fri, 3 Jan 2014 20:27:06 -0600 Subject: [PATCH] added chatterbonus(extra points for activity) --- lib/currency.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/currency.js b/lib/currency.js index 4a6e402..52896b1 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -74,6 +74,7 @@ function Currency(irc, db, options) { __self.config.subscribers_json = options.subscribers || ''; __self.config.website = options.website || ''; __self.config.modpowers = options.modpowers || false; + __self.config.chatterbonus = options.chatterbonus || false; // general settings __self.pre_text = '> ' + __self.config.currency + ': '; @@ -104,6 +105,7 @@ function Currency(irc, db, options) { __self.give_coins_timer = options.payrate || 30;//minutes __self.subscriber_check = 4;//minutes __self.subscribers = []; + __self.active_list = []; // raffle settings __self.raffle_status = false; @@ -143,6 +145,21 @@ Currency.prototype.commands = function (data) { // broadcaster only commands if (broadcaster_bot_initiated || (__self.config.modpowers && moderator_initiated)) { + //toggle chatter bonus + if (data[4] == 'chatterbonus') { + switch (data[5]) { + case 'on': + __self.config.chatterbonus = true; + __self.irc.emit('message', {message:__self.pre_text + 'Chatter bonus is on! Earn extra potatoes by being active in the chat.'}); + + break; + case 'off': + __self.config.chatterbonus = false; + __self.irc.emit('message', {message:__self.pre_text + 'Chatterbonus is now off. Potato deflation!'}); + + break; + } + } //open / close auction system if (data[4] === 'auction') { switch (data[5]) { @@ -597,19 +614,27 @@ Currency.prototype.handout_coins = function () { if (__self.viewer_list.indexOf(viewer) < 0) { __self.viewer_list.push(viewer); } + if (__self.active_list.indexOf(viewer) < 0) { + __self.active_list.push(viewer); + } } // give coins after \who and handout_coins is true if (__self.give_coins && data_split[3] == '315') { var clone_viewer_list = __self.viewer_list; + var clone_active_list = __self.active_list; // clear old list and start recording __self.viewer_list = []; + __self.active_list = []; // build sql from the saved viewer list var sql = ''; for (var i = 0; i < clone_viewer_list.length; i++) { var currency_amount = __self.subscribers.indexOf(clone_viewer_list[i]) >= 0 ? 2 : 1; + if (__self.config.chatterbonus){ + if(clone_active_list.indexOf(clone_viewer_list[i])) currecy_amount++; + } if (clone_viewer_list[i] !== '') { if (i != clone_viewer_list.length - 1) { sql += 'INSERT INTO viewers (user, points) '; @@ -628,6 +653,7 @@ Currency.prototype.handout_coins = function () { } } else { __self.viewer_list = []; + __self.active_list = []; } });