|
@ -855,32 +855,6 @@ Currency.prototype.handout_coins = function () { |
|
|
|
|
|
|
|
|
// get subscribers
|
|
|
// get subscribers
|
|
|
function subscribers() { |
|
|
function subscribers() { |
|
|
var time = utils.make_interval(__self.subscriber_check); |
|
|
|
|
|
if (time === 0) { |
|
|
|
|
|
// get stream status
|
|
|
|
|
|
http.get(__self.config.subscribers_json, function (response) { |
|
|
|
|
|
var body = ''; |
|
|
|
|
|
// put together response
|
|
|
|
|
|
response.on('data', function (chunk) { |
|
|
|
|
|
body += chunk; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// start / stop handing out coins based on stream status
|
|
|
|
|
|
response.on('end', function () { |
|
|
|
|
|
var json = JSON.parse(body); |
|
|
|
|
|
var entries = json.feed.entry, subs = ''; |
|
|
|
|
|
__self.subscribers = []; |
|
|
|
|
|
for (var i = 0; i < entries.length; i++) { |
|
|
|
|
|
__self.subscribers.push(entries[i].title['$t']); |
|
|
|
|
|
subs += entries[i].title['$t'] + ' '; |
|
|
|
|
|
} |
|
|
|
|
|
__self.irc.emit('data', 'DATA - Subscriber Check - Returned: ' + subs); |
|
|
|
|
|
setTimeout(subscribers, 1000); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
setTimeout(subscribers, time); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// trigger coin handout
|
|
|
// trigger coin handout
|
|
@ -2207,40 +2181,43 @@ Currency.prototype.bets_award_winner = function (winner) { |
|
|
// NEW STUFF
|
|
|
// NEW STUFF
|
|
|
Currency.prototype.add_quotation = function (data) { |
|
|
Currency.prototype.add_quotation = function (data) { |
|
|
var __self = this; |
|
|
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; |
|
|
|
|
|
if (broadcaster_bot_initiated || moderator_initiated) { |
|
|
|
|
|
|
|
|
// Chop all the shit out
|
|
|
// Chop all the shit out
|
|
|
data.splice(0, 4); |
|
|
data.splice(0, 4); |
|
|
data = data.join(' ') |
|
|
data = data.join(' ') |
|
|
|
|
|
|
|
|
sql = 'INSERT INTO quotes (`text`) VALUES (' + __self.db.string_escape(data) + ');'; |
|
|
sql = 'INSERT INTO quotes (`text`) VALUES (' + __self.db.string_escape(data) + ');'; |
|
|
__self.db.execute(sql, function() { |
|
|
|
|
|
__self.irc.emit('message', {message:__self.pre_text + ' New quote added!'}); |
|
|
|
|
|
|
|
|
__self.db.execute(sql, function(rows, fields) { |
|
|
|
|
|
__self.irc.emit('message', {message:__self.pre_text + ' New quote added!' + ' ['+rows.insertId+']'}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Currency.prototype.remove_quotation = function(data) { |
|
|
Currency.prototype.remove_quotation = function(data) { |
|
|
var __self = this; |
|
|
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; |
|
|
|
|
|
if (broadcaster_bot_initiated || moderator_initiated) { |
|
|
|
|
|
|
|
|
// Chop all the shit out
|
|
|
// Chop all the shit out
|
|
|
data.splice(0, 4); |
|
|
data.splice(0, 4); |
|
|
if (data === parseInt(data, 10)) { |
|
|
|
|
|
|
|
|
if (data == parseInt(data, 10)) { |
|
|
__self.db.execute('DELETE FROM quotes WHERE id=\''+parseInt(data, 10)+'\';', function(rows) { |
|
|
__self.db.execute('DELETE FROM quotes WHERE id=\''+parseInt(data, 10)+'\';', function(rows) { |
|
|
__self.irc.emit('message', {message:__self.pre_text + 'Quote #'+data+' deleted!'}); |
|
|
__self.irc.emit('message', {message:__self.pre_text + 'Quote #'+data+' deleted!'}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Currency.prototype.get_quotation = function() { |
|
|
Currency.prototype.get_quotation = function() { |
|
|
var __self = this; |
|
|
var __self = this; |
|
|
|
|
|
|
|
|
// Let's get the number of quotes in database (should store this on its own later) TODO
|
|
|
|
|
|
__self.db.execute('SELECT COUNT(*) AS quoteCount FROM quotes;', function(rows) { |
|
|
|
|
|
var quote_count = rows[0].quoteCount; |
|
|
|
|
|
var selected_quote_id = Math.floor(Math.random() * (quote_count - 0 + 1) + 1); |
|
|
|
|
|
__self.db.execute('SELECT * FROM quotes WHERE id=\''+selected_quote_id+'\';', function(rows) { |
|
|
|
|
|
|
|
|
__self.db.execute('SELECT * FROM quotes ORDER BY RAND() LIMIT 1;', function(rows) { |
|
|
__self.irc.emit('message', {message:__self.pre_text + rows[0].id + ': ' + rows[0].text}); |
|
|
__self.irc.emit('message', {message:__self.pre_text + rows[0].id + ': ' + rows[0].text}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = function (irc, db, commands, options) { |
|
|
module.exports = function (irc, db, commands, options) { |
|
|