|
|
@ -236,7 +236,7 @@ Currency.prototype.commands = function (data) { |
|
|
|
switch (data[5]) { |
|
|
|
case 'open': |
|
|
|
if (data[6] && data[7] && !__self.raffle_status) { |
|
|
|
if(parseInt(data[6], 10) > 0 && parseInt(data[7], 10) > 0) { |
|
|
|
if(parseInt(data[6], 10) >= 0 && parseInt(data[7], 10) > 0) { |
|
|
|
// save default values
|
|
|
|
__self.temp.raffle_ticket_cost = __self.raffle_ticket_cost; |
|
|
|
__self.temp.raffle_max_tickets = __self.raffle_max_tickets; |
|
|
@ -468,8 +468,18 @@ Currency.prototype.commands = function (data) { |
|
|
|
case '!exchange': |
|
|
|
if(Object.keys(__self.config.exchanges).length != 0) |
|
|
|
__self.currency_exchange(__self.irc.caller(data[0]), parseInt(data[4], 10), data[5]); |
|
|
|
break; |
|
|
|
case '!addquote': |
|
|
|
__self.add_quotation(data); |
|
|
|
break; |
|
|
|
case '!delquote': |
|
|
|
__self.remove_quotation(data); |
|
|
|
break; |
|
|
|
case '!quote': |
|
|
|
__self.get_quotation(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// place a bet
|
|
|
|
if (__self.bets_status === true) { |
|
|
|
for (var i = 0; i < __self.bets_board.length; i++) { |
|
|
@ -2194,6 +2204,45 @@ Currency.prototype.bets_award_winner = function (winner) { |
|
|
|
__self.bets_total = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
// NEW STUFF
|
|
|
|
Currency.prototype.add_quotation = function (data) { |
|
|
|
var __self = this; |
|
|
|
|
|
|
|
// Chop all the shit out
|
|
|
|
data.splice(0, 4); |
|
|
|
data = data.join(' ') |
|
|
|
|
|
|
|
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!'}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
Currency.prototype.remove_quotation = function(data) { |
|
|
|
var __self = this; |
|
|
|
|
|
|
|
// Chop all the shit out
|
|
|
|
data.splice(0, 4); |
|
|
|
if (data === parseInt(data, 10)) { |
|
|
|
__self.db.execute('DELETE FROM quotes WHERE id=\''+parseInt(data, 10)+'\';', function(rows) { |
|
|
|
__self.irc.emit('message', {message:__self.pre_text + 'Quote #'+data+' deleted!'}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
Currency.prototype.get_quotation = function() { |
|
|
|
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.irc.emit('message', {message:__self.pre_text + rows[0].id + ': ' + rows[0].text}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = function (irc, db, commands, options) { |
|
|
|
return new Currency(irc, db, commands, options); |
|
|
|
}; |