sometimes i think i might be retarded

This commit is contained in:
reality 2013-01-23 16:12:08 +00:00
parent ff6a296aea
commit b12259643a

View File

@ -1,6 +1,7 @@
var _ = require('underscore')._; var _ = require('underscore')._;
var commands = function(dbot) { var commands = function(dbot) {
var quotes = dbot.db.quoteArrs;
var commands = { var commands = {
// Alternative syntax to ~q // Alternative syntax to ~q
'~': function(event) { '~': function(event) {
@ -26,7 +27,6 @@ var commands = function(dbot) {
}, },
'~rmdeny': function(event) { '~rmdeny': function(event) {
var quotes = this.quotes;
var rmCache = this.rmCache; var rmCache = this.rmCache;
var rmCacheCount = rmCache.length; var rmCacheCount = rmCache.length;
for(var i=0;i<rmCacheCount;i++) { for(var i=0;i<rmCacheCount;i++) {
@ -55,7 +55,6 @@ var commands = function(dbot) {
// Shows a list of the biggest categories // Shows a list of the biggest categories
'~qstats': function(event) { '~qstats': function(event) {
var quotes = this.quotes;
var qSizes = _.chain(quotes) var qSizes = _.chain(quotes)
.pairs() .pairs()
.sortBy(function(category) { return category[1].length }) .sortBy(function(category) { return category[1].length })
@ -74,7 +73,6 @@ var commands = function(dbot) {
// Search a given category for some text. // Search a given category for some text.
// TODO fix // TODO fix
'~qsearch': function(event) { '~qsearch': function(event) {
var quotes = this.quotes;
var haystack = event.input[1].trim().toLowerCase(); var haystack = event.input[1].trim().toLowerCase();
var needle = event.input[2]; var needle = event.input[2];
if(_.has(quotes, haystack)) { if(_.has(quotes, haystack)) {
@ -98,7 +96,6 @@ var commands = function(dbot) {
}, },
'~rmlast': function(event) { '~rmlast': function(event) {
var quotes = this.quotes;
if(this.rmAllowed == true || _.include(dbot.config.admins, event.user)) { if(this.rmAllowed == true || _.include(dbot.config.admins, event.user)) {
var key = event.input[1].trim().toLowerCase(); var key = event.input[1].trim().toLowerCase();
if(_.has(quotes, key)) { if(_.has(quotes, key)) {
@ -122,7 +119,6 @@ var commands = function(dbot) {
'~rm': function(event) { '~rm': function(event) {
if(this.rmAllowed == true || _.include(dbot.config.admins, event.user)) { if(this.rmAllowed == true || _.include(dbot.config.admins, event.user)) {
var quotes = this.quotes;
var key = event.input[1].trim().toLowerCase(); var key = event.input[1].trim().toLowerCase();
var quote = event.input[2]; var quote = event.input[2];
@ -150,7 +146,6 @@ var commands = function(dbot) {
'~qcount': function(event) { '~qcount': function(event) {
var input = event.message.valMatch(/^~qcount ([\d\w\s-]*)/, 2); var input = event.message.valMatch(/^~qcount ([\d\w\s-]*)/, 2);
var quotes = this.quotes;
if(input) { // Give quote count for named category if(input) { // Give quote count for named category
var key = input[1].trim().toLowerCase(); var key = input[1].trim().toLowerCase();
if(_.has(quotes, key)) { if(_.has(quotes, key)) {
@ -170,7 +165,6 @@ var commands = function(dbot) {
}, },
'~qadd': function(event) { '~qadd': function(event) {
var quotes = this.quotes;
var key = event.input[1].toLowerCase(); var key = event.input[1].toLowerCase();
var text = event.input[2]; var text = event.input[2];
if(!_.isArray(quotes[key])) { if(!_.isArray(quotes[key])) {
@ -193,14 +187,13 @@ var commands = function(dbot) {
}, },
'~rq': function(event) { '~rq': function(event) {
var quotes = this.quotes;
var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)]; var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)];
event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event, category)); event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event, category));
}, },
'~link': function(event) { '~link': function(event) {
var key = event.params[1].trim().toLowerCase(); var key = event.params[1].trim().toLowerCase();
if(_.has(this.quotes, key)) { if(_.has(quotes, key)) {
event.reply(dbot.t('quote_link', { event.reply(dbot.t('quote_link', {
'category': key, 'category': key,
'url': dbot.t('url', { 'url': dbot.t('url', {